"""Functional tests for fetching transactions for statement period.""" from tests.testutils import db, mock_auth @db.test_schema_default_seed def test_get_statement_transactions_for_period(auth_client, mocker): """Test get statement periods handler.""" mock_auth(mocker, 24601) result = auth_client.get("/statement-period/1/transactions") assert result.json == { "items": [ { "chargeable_amount": 9001.0, "collaborator_id": 20, "collaborator_share": 1.0, "created_date": "2020-02-03T04:05:06", "currency": "USD", "current_balance": 0, "date": "2018-10-09", "deleted_date": None, "description": "Report revenue", "id": 7, "original_amount": 9001.0, "report_id": 5, "statement_period_id": 1, "transferwise_transaction_id": 2, "type": "CREDIT", "voided_transaction_id": None, "credited_payment_id": None, "creation_batch_uuid": None, }, { "chargeable_amount": -100.0, "collaborator_id": 1, "collaborator_share": 1.0, "created_date": "2019-11-10T09:08:07", "currency": "USD", "current_balance": 0, "date": "2019-11-10", "deleted_date": None, "description": "Expense", "id": 3, "original_amount": -100.0, "report_id": None, "statement_period_id": 1, "transferwise_transaction_id": None, "type": "EXPENSE", "voided_transaction_id": None, "credited_payment_id": None, "creation_batch_uuid": None, }, { "chargeable_amount": -50.0, "collaborator_id": 1, "collaborator_share": 1.0, "created_date": "2019-10-09T08:07:06", "currency": "USD", "current_balance": 0, "date": "2019-10-09", "deleted_date": None, "description": "Payment", "id": 2, "original_amount": -50.0, "report_id": 1, "statement_period_id": 1, "transferwise_transaction_id": 1, "type": "PAYMENT", "voided_transaction_id": None, "credited_payment_id": None, "creation_batch_uuid": None, }, { "chargeable_amount": 100.0, "collaborator_id": 1, "collaborator_share": 1.0, "created_date": "2019-09-08T07:06:05", "currency": "USD", "current_balance": 0, "date": "2019-09-08", "deleted_date": None, "description": "Manual revenue", "id": 1, "original_amount": 100.0, "report_id": None, "statement_period_id": 1, "transferwise_transaction_id": None, "type": "REVENUE", "voided_transaction_id": None, "credited_payment_id": None, "creation_batch_uuid": None, }, ], "pagination": {"total_records": 4, "type": "standard"}, } assert result.status_code == 200 @db.test_schema_default_seed def test_get_statement_transactions_for_period_not_found(auth_client, mocker): """Test get statement periods handler.""" mock_auth(mocker, 420) result = auth_client.get("/statement-period/666/transactions") assert result.json == { "items": [], "pagination": {"total_records": 0, "type": "standard"}, } assert result.status_code == 200