- Implement tests for basic and bearer authentication headers in `test_auth.py`. - Create tests for the `EasybillWebhookParser` in `test_webhooks.py`, covering JSON and form-encoded payloads, as well as a generic parse and acknowledgement method.
59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
SPEC = ROOT / "swagger.json"
|
|
OUTPUT_ROOT = ROOT / "generated"
|
|
|
|
|
|
def build_command(mode: str) -> list[str]:
|
|
library = "httpx" if mode == "sync" else "asyncio"
|
|
package_name = f"easybill_generated_{mode}"
|
|
project_name = f"easybill-generated-{mode}"
|
|
output_path = OUTPUT_ROOT / mode
|
|
|
|
return [
|
|
"docker",
|
|
"run",
|
|
"--rm",
|
|
"-v",
|
|
f"{ROOT}:/local",
|
|
"openapitools/openapi-generator-cli",
|
|
"generate",
|
|
"-i",
|
|
"/local/swagger.json",
|
|
"-g",
|
|
"python",
|
|
"-o",
|
|
f"/local/generated/{mode}",
|
|
"--skip-validate-spec",
|
|
"--additional-properties",
|
|
f"library={library},packageName={package_name},projectName={project_name},hideGenerationTimestamp=true",
|
|
]
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description="Generate the raw easybill client from swagger.json")
|
|
parser.add_argument("--mode", choices=["sync", "async", "both"], default="both")
|
|
args = parser.parse_args()
|
|
|
|
if not SPEC.exists():
|
|
raise SystemExit("swagger.json not found")
|
|
|
|
OUTPUT_ROOT.mkdir(exist_ok=True)
|
|
modes = ["sync", "async"] if args.mode == "both" else [args.mode]
|
|
|
|
for mode in modes:
|
|
command = build_command(mode)
|
|
print("Running:", " ".join(command))
|
|
subprocess.run(command, check=True)
|
|
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|