Skip to content

Commit 6f4ecf5

Browse files
committed
docs: pytest
1 parent 8a0f4de commit 6f4ecf5

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Turbo is a simple bootstrap template for Django and Next.js, combining both fram
3535
- [Updating OpenAPI schema](#updating-openapi-schema)
3636
- [Swagger](#swagger)
3737
- [Client side requests](#client-side-requests)
38+
- [Test suite](#test-suite)
3839
- [Developing in VS Code](#developing-in-vs-code)
3940

4041
## Quickstart
@@ -243,6 +244,36 @@ By default, Turbo includes Swagger for API schema which is available here `http:
243244

244245
At the moment, Turbo does not contain any examples of client side requests towards the backend. All the requests are handled by server actions. For client side requests, it is recommended to use [react-query](https://github.com/TanStack/query).
245246

247+
## Test suite
248+
249+
Project contains test suite for backend part. For testing it was used library called [pytest](https://docs.pytest.org/en/latest/) along with some additinal libraries extending functionality of pytest:
250+
251+
- [pytest-django](https://pytest-django.readthedocs.io/en/latest/) - for testing django applications
252+
- [pytest-factoryboy](https://pytest-factoryboy.readthedocs.io/en/latest/) - for creating test data
253+
254+
All these libraries mentioned above are already preconfigured in `backend/api/tests` directory.
255+
256+
- `conftest.py` - for configuring pytest
257+
- `factories.py` - for generating reusable test objects using factory_boy, which creates model instances with default values that can be customized as needed
258+
- `fixtures.py` - for creating pytest fixtures that provide test data or resources that can be shared and reused across multiple tests
259+
260+
To run tests, use the command below which will collect all the tests available in backend/api/tests folder:
261+
262+
```bash
263+
docker compose exec api uv run -- pytest .
264+
```
265+
266+
Tu run tests available only in one specific file run:
267+
268+
```bash
269+
docker compose exec api uv run -- pytest api/tests/test_api.py
270+
```
271+
272+
To run one specific test, use the command below:
273+
274+
```bash
275+
docker compose exec api uv run -- pytest api/tests/test_api.py -k "test_api_users_me_authorized"
276+
```
246277

247278
## Developing in VS Code
248279

0 commit comments

Comments
 (0)