Fix export csv - #31
Conversation
📝 WalkthroughWalkthroughThe PR updates transaction CSV export to derive the amount field from ChangesTransaction CSV Export Amount Formatting
🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_routes.py (1)
123-129: ⚡ Quick winAssert the exported
amountformat explicitly.This test validates CSV presence but not the new cents→dollars formatting behavior. Add an assertion that exported
amountvalues are two-decimal strings.Proposed test hardening
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 + import csv + from io import StringIO + rows = list(csv.DictReader(StringIO(response.data.decode('utf-8')))) + assert rows, "Expected at least one exported transaction row" + for row in rows: + whole, dot, frac = row['amount'].partition('.') + assert dot == '.' and len(frac) == 2 and whole.isdigit()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_routes.py` around lines 123 - 129, In test_export_transactions_csv, add an assertion that the exported CSV's amount column uses two-decimal dollar formatting by parsing response.data (or decoding to text) and verifying the amount fields match a two-decimal pattern (e.g. regex like ^\d+\.\d{2}$) for one or more sample rows from the CSV produced by the sample_transactions fixture; update the test_export_transactions_csv function to extract the CSV rows from response.data and assert the amount strings conform to the two-decimal format.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_routes.py`:
- Around line 123-129: In test_export_transactions_csv, add an assertion that
the exported CSV's amount column uses two-decimal dollar formatting by parsing
response.data (or decoding to text) and verifying the amount fields match a
two-decimal pattern (e.g. regex like ^\d+\.\d{2}$) for one or more sample rows
from the CSV produced by the sample_transactions fixture; update the
test_export_transactions_csv function to extract the CSV rows from response.data
and assert the amount strings conform to the two-decimal format.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 44620ae5-92f0-4f75-a8b4-aff56cf3460f
📒 Files selected for processing (2)
JustAnotherExpenseManager/routes/transactions.pytests/test_routes.py
Summary by CodeRabbit
Bug Fixes
Tests