You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
│ ├── __init__.py # Initialization file for the app package.
@@ -737,13 +737,13 @@ class EntityDelete(BaseModel):
737
737
Then, while in the `src` folder, run Alembic migrations:
738
738
739
739
```sh
740
-
poetry run alembic revision --autogenerate
740
+
uv run alembic revision --autogenerate
741
741
```
742
742
743
743
And to apply the migration
744
744
745
745
```sh
746
-
poetry run alembic upgrade head
746
+
uv run alembic upgrade head
747
747
```
748
748
749
749
### 5.6 CRUD
@@ -1299,7 +1299,7 @@ If you are using `docker compose`, the worker is already running.
1299
1299
If you are doing it from scratch, run while in the `root` folder:
1300
1300
1301
1301
```sh
1302
-
poetry run arq src.app.core.worker.settings.WorkerSettings
1302
+
uv run arq src.app.core.worker.settings.WorkerSettings
1303
1303
```
1304
1304
1305
1305
#### Database session with background tasks
@@ -1512,13 +1512,13 @@ If you are doing it from scratch, ensure your postgres and your redis are runnin
1512
1512
while in the `root` folder, run to start the application with uvicorn server:
1513
1513
1514
1514
```sh
1515
-
poetry run uvicorn src.app.main:app --reload
1515
+
uv run uvicorn src.app.main:app --reload
1516
1516
```
1517
1517
1518
1518
And for the worker:
1519
1519
1520
1520
```sh
1521
-
poetry run arq src.app.core.worker.settings.WorkerSettings
1521
+
uv run arq src.app.core.worker.settings.WorkerSettings
1522
1522
```
1523
1523
### 5.14 Create Application
1524
1524
@@ -1834,74 +1834,101 @@ And finally, on your browser: `http://localhost/docs`.
1834
1834
1835
1835
## 7. Testing
1836
1836
1837
-
While in the tests folder, create your test file with the name "test\_{entity}.py", replacing entity with what you're testing
1837
+
This project uses **fast unit tests** that don't require external services like databases or Redis. Tests are isolated using mocks and run in milliseconds.
1838
+
1839
+
### 7.1 Writing Tests
1840
+
1841
+
Create test files with the name `test_{entity}_unit.py` in the `tests/` folder, replacing `{entity}` with what you're testing:
1838
1842
1839
1843
```sh
1840
-
touch test_items.py
1844
+
touch tests/test_items_unit.py
1841
1845
```
1842
1846
1843
-
Finally create your tests (you may want to copy the structure in test_user.py)
1847
+
Follow the structure in `tests/test_user_unit.py` for examples. Our tests use:
1844
1848
1845
-
Now, to run:
1849
+
- **pytest** with **pytest-asyncio** for async support
1850
+
- **unittest.mock** for mocking dependencies
1851
+
- **AsyncMock** for async function mocking
1852
+
- **Faker** for generating test data
1846
1853
1847
-
### 7.1 Docker Compose
1854
+
Example test structure:
1848
1855
1849
-
First you need to uncomment the following part in the `docker-compose.yml` file:
0 commit comments