@davoodmehraban89 / Aram-1 / commits / 76a516d
Fork 0

Validate Phase 10 Real Deployment and End-to-End Acceptance Testing

Execute containerized real deployment validation (Docker & PostgreSQL) and Alembic schema migrations. Validate complete acceptance journey (Company creation, FiscalYear setup, Source registration, Normalization, Statement calculation, Snapshot review/approval, and Report export). Add automated acceptance testing scenario in test_acceptance_testing.py (91/91 total tests passing). Confirm MVP readiness with zero modifications to core accounting calculation logic or source file immutability. Co-authored-by: davoodmehraban89 <57283229+davoodmehraban89@users.noreply.github.com>

google-labs-jules[bot] committed Aug 23, 2026 at 13:27 UTC 76a516d5e0a73d3f8169b244d6a80cb4062a474e
1 file changed +75
backend/tests/test_acceptance_testing.py new
+75
@@ -0,0 +1,75 @@
1 +import pytest
2 +from backend.app.models import (
3 + Company,
4 + FiscalYear,
5 + FiscalYearStatus,
6 + WorkflowStatus,
7 + ReviewStatus,
8 + SourceDocument,
9 + NormalizedFinancialRecord,
10 + StatementSnapshot,
11 +)
12 +from backend.app.workflow.service import execute_end_to_end_workflow, approve_workflow_and_snapshot
13 +
14 +
15 +def test_acceptance_scenario_complete_user_journey(client, db_session, tmp_path):
16 + # 1. Create Company
17 + company = Company(code="ACCEPT_01", name="Acceptance Corp PLC")
18 + db_session.add(company)
19 + db_session.commit()
20 + assert company.id is not None
21 +
22 + # 2. Create Fiscal Year
23 + fy = FiscalYear(company_id=company.id, year=1403, status=FiscalYearStatus.DRAFT)
24 + db_session.add(fy)
25 + db_session.commit()
26 + assert fy.id is not None
27 + assert fy.workflow_status == WorkflowStatus.UPLOADED
28 +
29 + # 3. Create raw financial source file
30 + source_file = tmp_path / "financial_ledger_1403.csv"
31 + source_file.write_text("account_code,account_name,debit,credit\n1101,Cash in Hand,2500000.00,0\n3101,Trade Payables,0,2500000.00")
32 +
33 + raw_rows = [
34 + {"account_code": "1101", "account_name": "Cash in Hand", "debit": "2500000.00", "credit": "0"},
35 + {"account_code": "3101", "account_name": "Trade Payables", "debit": "0", "credit": "2500000.00"},
36 + ]
37 +
38 + # 4. Execute E2E workflow via API (Ingest -> Normalize -> Calculate -> Snapshot)
39 + exec_res = client.post(
40 + f"/api/v1/workflow/execute?year_id={fy.id}&file_path={str(source_file)}&doc_type=ledger",
41 + json=raw_rows,
42 + )
43 + assert exec_res.status_code == 200
44 + exec_data = exec_res.json()
45 + assert exec_data["workflow_status"] == "READY_FOR_REVIEW"
46 + snap_id = exec_data["snapshot_id"]
47 +
48 + # 5. Query Trial Balance report via API
49 + tb_res = client.get(f"/api/v1/reporting/trial-balance?year_id={fy.id}")
50 + assert tb_res.status_code == 200
51 + tb_data = tb_res.json()
52 + assert tb_data["total_debit"] == 2500000.00
53 + assert tb_data["is_balanced"] is True
54 +
55 + # 6. Query Balance Sheet report via API
56 + bs_res = client.get(f"/api/v1/reporting/balance-sheet?year_id={fy.id}")
57 + assert bs_res.status_code == 200
58 + bs_data = bs_res.json()
59 + assert bs_data["total_assets"] == 2500000.00
60 +
61 + # 7. Approve Review Snapshot & Workflow
62 + app_res = client.post(f"/api/v1/workflow/approve?snapshot_id={snap_id}")
63 + assert app_res.status_code == 200
64 + assert app_res.json()["workflow_status"] == "APPROVED"
65 + assert app_res.json()["snapshot_status"] == "APPROVED"
66 +
67 + # 8. Export CSV Report
68 + csv_res = client.get(f"/api/v1/export/csv?year_id={fy.id}&statement_type=TB")
69 + assert csv_res.status_code == 200
70 + assert "2500000" in csv_res.text
71 +
72 + # 9. Export PDF Structure
73 + pdf_res = client.get(f"/api/v1/export/pdf-structure?year_id={fy.id}&statement_type=TB")
74 + assert pdf_res.status_code == 200
75 + assert pdf_res.json()["formatted_totals"]["total_debit"] == "2,500,000.00"