Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setup fastapi tests #223

Merged
merged 5 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ tests: backend_tests
backend_tests:
@echo "🍜 Running python tests"
${DOCKER_COMPOSE_TEST} up -d neo4j
${DOCKER_COMPOSE_TEST} run --rm taxonomy_api pytest . /parser
${DOCKER_COMPOSE_TEST} run --rm taxonomy_api pytest /parser /parser
${DOCKER_COMPOSE_TEST} run --rm taxonomy_api pytest /code/tests
${DOCKER_COMPOSE_TEST} stop neo4j

checks: quality tests
Expand Down
1 change: 1 addition & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RUN groupadd -g $USER_GID off && \

COPY backend/requirements*.txt /code/
COPY backend/editor /code/editor
COPY backend/tests /code/tests
alexgarel marked this conversation as resolved.
Show resolved Hide resolved
COPY parser /parser

RUN pip3 install --no-cache-dir --upgrade -r /code/$REQUIREMENTS_FILE
Expand Down
2 changes: 2 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ watchfiles==0.18.1
websockets==10.3
PyGithub==1.56
python-multipart==0.0.5
httpx==0.23.3
pytest==7.1.2
-e ../parser/
Empty file added backend/tests/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from fastapi.testclient import TestClient
import pytest

from editor.api import app

@pytest.fixture
def client():
with TestClient(app) as client:
yield client
4 changes: 4 additions & 0 deletions backend/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def test_hello(client):
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Hello user! Tip: open /docs or /redoc for documentation"}