Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion JustAnotherExpenseManager/routes/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def export_transactions() -> Response:
for trans in all_transactions:
writer.writerow([
trans.description,
f'{trans.amount_dollars:.2f}',
f'{(trans.amount_cents / 100):.2f}',
trans.type.value,
trans.category or '',
trans.date,
Expand Down
7 changes: 7 additions & 0 deletions tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ def test_update_transaction_invalid_type_returns_400(self, client, db):
})
assert response.status_code == 400

def test_export_transactions_csv(self, client, sample_transactions):
response = client.get('/api/transactions/export')
assert response.status_code == 200
assert response.headers['Content-Disposition'].startswith('attachment; filename=')
assert b'description,amount,type,category,date,tags' in response.data
assert b'Restaurant' in response.data


# ---------------------------------------------------------------------------
# Transaction filtering and pagination
Expand Down
Loading