mentoria-api-flask/tests/test_invoices.py

16 lines
491 B
Python

from tests.factories import InvoiceFactory
from tests.utils import get_auth_token
def test_get_invoices(client, db_session):
"""Testa a listagem de faturas"""
token = get_auth_token(client)
InvoiceFactory.create_batch(2) # Cria 2 faturas fictícias
db_session.commit()
response = client.get("/invoices/", headers={"Authorization": f"Bearer {token}"})
print(response)
assert response.status_code == 200
data = response.get_json()
assert len(data) == 2