Spaces:
Sleeping
Sleeping
from fastapi.testclient import TestClient | |
import pytest | |
from app.model.transaction import Transaction | |
from app.model.user import User | |
from sqlalchemy.ext.asyncio import AsyncSession | |
from tests.utils import get_fake_transactions | |
async def test_transactions(client: TestClient, get_db_session_fixture: AsyncSession) -> None: | |
session_override = get_db_session_fixture | |
# 1. Create a user | |
user = await User.create(session_override, name="user", email="email", hashed_password="password") | |
# 2. Create a bunch of transactions | |
fake_transactions = get_fake_transactions(user.id) | |
await Transaction.bulk_create(session_override, fake_transactions) | |
# 3. Verify that the transactions are returned | |
response = client.get("/api/v1/transactions/1") | |
assert response.status_code == 200 | |
assert len(response.json()) == 10 |