Spaces:
Sleeping
Sleeping
File size: 868 Bytes
b905bd6 4761dd9 b905bd6 4761dd9 b905bd6 4761dd9 b905bd6 4761dd9 b905bd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 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
@pytest.mark.asyncio
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 |