Skip to content

Commit

Permalink
Merge pull request #9 from FredHutch/test-api
Browse files Browse the repository at this point in the history
added python setup for running tests against PROOF API
  • Loading branch information
sckott authored Dec 16, 2024
2 parents 42bce5b + 98d22cc commit f456447
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
uv.lock
.pytest_cache

# Virtual environments
.venv
.env
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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",
]
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
python_files = test-*.py
testpaths = tests
Empty file added tests/__init__.py
Empty file.
29 changes: 29 additions & 0 deletions tests/proof-api/test-api-basics.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f456447

Please sign in to comment.