Skip to content

Commit

Permalink
Install pytest, pytest-cov & httpx. Basic test_api file. Update docum…
Browse files Browse the repository at this point in the history
…entation
  • Loading branch information
raphodn committed Nov 15, 2023
1 parent a5a544e commit aa41163
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ pre-commit install
```

Now `pre-commit` will run automatically on `git commit` :)

## Write and run tests

You should create unit tests for each new feature or API change (see [test_api.py](https://github.com/openfoodfacts/open-prices/blob/main/tests/test_api.py)).

To run tests, just launch:
```bash
pytest
```
132 changes: 131 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ sqlalchemy-utils = "~0.41.1"
uvicorn = "~0.23.2"
fastapi-pagination = "^0.12.12"
fastapi-filter = "^1.0.0"
pytest = "^7.4.3"
pytest-cov = "^4.1.0"
httpx = "^0.25.1"


[tool.poetry.group.dev.dependencies]
Expand Down
11 changes: 11 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from fastapi.testclient import TestClient

from app.api import app


client = TestClient(app)


def test_hello():
response = client.get("/")
assert response.status_code == 200

0 comments on commit aa41163

Please sign in to comment.