Skip to content

Commit

Permalink
Basic test_api file. Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Nov 13, 2023
1 parent c82f63c commit 578ba76
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ repos:
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: name-tests-test
- id: requirements-txt-fixer
- id: name-tests-test
args: [--pytest-test-first]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.5.0
hooks:
Expand Down
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
```
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 578ba76

Please sign in to comment.