diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.yml new file mode 100644 index 0000000..c409a22 --- /dev/null +++ b/.github/workflows/api-tests.yml @@ -0,0 +1,28 @@ +name: API Tests + +on: + push: + branches: + - main + - dev + - test-api + workflow_dispatch: + +jobs: + api-tests: + runs-on: self-hosted + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "0.5.8" + + - name: Set up Python + run: uv python install 3.13 + + - name: Run tests + env: + PROOF_API_TOKEN_DEV: ${{ secrets.PROOF_API_TOKEN_DEV }} + run: uv run pytest tests/proof-api/ --verbose diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e32c0b --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Python-generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info +uv.lock +.pytest_cache + +# Virtual environments +.venv +.env diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..24ee5b1 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..63782ce --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,10 @@ +[project] +name = "wdl-unit-tests" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.13" +dependencies = [ + "httpx>=0.28.1", + "pytest>=8.3.4", +] diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..0e0a68f --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +python_files = test-*.py +testpaths = tests diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/proof-api/test-api-basics.py b/tests/proof-api/test-api-basics.py new file mode 100644 index 0000000..de382ac --- /dev/null +++ b/tests/proof-api/test-api-basics.py @@ -0,0 +1,29 @@ +import os + +import httpx + +BASE_URL = "https://proof-api-dev.fredhutch.org" +# test user token +TOKEN = os.getenv("PROOF_API_TOKEN_DEV") +headers = {"Authorization": f"Bearer {TOKEN}"} +info_keys = ["branch", "commit_sha", "short_commit_sha", "commit_message", "tag"] +status_keys = [ + "canJobStart", + "jobStatus", + "cromwellUrl", + "jobStartTime", + "jobEndTime", + "jobInfo", +] + + +def test_info(): + res = httpx.get(f"{BASE_URL}/info") + assert isinstance(res, httpx.Response) + assert list(res.json().keys()) == info_keys + + +def test_status(): + res = httpx.get(f"{BASE_URL}/cromwell-server", headers=headers, timeout=10) + assert isinstance(res, httpx.Response) + assert list(res.json().keys()) == status_keys