Create a testing collection
(
client: TestClient, normal_user_token_headers: dict[str, str]
)
| 18 | |
| 19 | @pytest.fixture |
| 20 | def test_collection( |
| 21 | client: TestClient, normal_user_token_headers: dict[str, str] |
| 22 | ) -> dict[str, Any]: |
| 23 | """Create a testing collection""" |
| 24 | collection_data = CollectionCreate(name="Test Collection") |
| 25 | rsp = client.post( |
| 26 | f"{settings.API_V1_STR}/collections/", |
| 27 | json=collection_data.model_dump(), |
| 28 | headers=normal_user_token_headers, |
| 29 | ) |
| 30 | assert rsp.status_code == 200 |
| 31 | collection = rsp.json() |
| 32 | |
| 33 | card_count = 3 |
| 34 | for i in range(card_count): |
| 35 | card_data = CardCreate(front=f"Test front {i}", back=f"Test back {i}") |
| 36 | rsp = client.post( |
| 37 | f"{settings.API_V1_STR}/collections/{collection['id']}/cards", |
| 38 | json=card_data.model_dump(), |
| 39 | headers=normal_user_token_headers, |
| 40 | ) |
| 41 | assert rsp.status_code == 200 |
| 42 | |
| 43 | return collection |
| 44 | |
| 45 | |
| 46 | @pytest.fixture |
nothing calls this directly
no test coverage detected