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 all 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
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.
10 changes: 10 additions & 0 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import pytest
from fastapi.testclient import TestClient

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"}
1 change: 1 addition & 0 deletions docker/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
volumes:
# in development mode, mount code directory dynamically
- ./backend/editor:/code/editor
- ./backend/tests:/code/tests
- ./parser:/parser
# for linting / checks purpose
- ./backend/pyproject.toml:/code/pyproject.toml
Expand Down