Skip to content

Commit 36369f0

Browse files
implements integration tests (#30)
1 parent c2022dc commit 36369f0

File tree

7 files changed

+35
-1
lines changed

7 files changed

+35
-1
lines changed

conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import pytest
2+
from fastapi.testclient import TestClient
3+
from typing import Iterator
4+
from main import app
5+
6+
7+
@pytest.fixture
8+
def client() -> Iterator[TestClient]:
9+
with TestClient(app) as client:
10+
yield client

dev.Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM kernai/refinery-parent-images:v1.15.0-mini
2+
3+
WORKDIR /app
4+
5+
COPY requirements*.txt .
6+
7+
RUN pip3 install --no-cache-dir -r requirements-dev.txt
8+
9+
COPY / .
10+
11+
CMD [ "/usr/local/bin/uvicorn", "--host", "0.0.0.0", "--port", "80", "main:app", "--reload"]

requirements-dev.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-r requirements.txt
2+
httpx==0.25.0
3+
pytest==8.1.1

run-tests

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker exec -it refinery-authorizer sh -c "cd /app && python3 -m pytest -v"

start

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ docker stop refinery-authorizer > /dev/null 2>&1
66
echo -ne '\t [done]\n'
77

88
echo -ne 'building container...'
9-
docker build -t refinery-authorizer-dev -f Dockerfile . > /dev/null 2>&1
9+
docker build -t refinery-authorizer-dev -f dev.Dockerfile . > /dev/null 2>&1
1010
echo -ne '\t\t [done]\n'
1111

1212
echo -ne 'starting...'

tests/__init__.py

Whitespace-only changes.

tests/test_main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from fastapi.testclient import TestClient
2+
3+
4+
def test_healthcheck(client: TestClient):
5+
response = client.get("/healthcheck")
6+
assert response.status_code == 200
7+
assert response.text == "OK"

0 commit comments

Comments
 (0)