fix: align reporting forms and demo analytics
All checks were successful
CI/CD Pipeline / Code Quality Checks (push) Successful in 2m21s
CI/CD Pipeline / Run Tests (push) Successful in 4m23s
CI/CD Pipeline / Build and Push Dev Images (push) Successful in 32s
CI/CD Pipeline / Deploy Dev via Compose (push) Successful in 52s

This commit is contained in:
2026-07-28 11:07:47 +02:00
parent ff0b2bdfca
commit df0f41b9c0
31 changed files with 1627 additions and 328 deletions

View File

@@ -0,0 +1,41 @@
"""Integration checks for the versioned Excel demo-period fixtures."""
import re
from pathlib import Path
from apps.form_3.services import FormF3Parser
from apps.form_4.services import FormF4Parser
from apps.form_6.services import FormF6Parser
from django.test import TestCase
DEMO_DIR = Path(__file__).resolve().parents[3] / "input" / "demo-periods"
class DemoPeriodWorkbooksTest(TestCase):
def test_form_f3_workbooks_match_current_schema(self):
for path in sorted(DEMO_DIR.glob("Ф-3_*.xlsx")):
year = int(re.search(r"_(\d{4})", path.name).group(1))
with self.subTest(path=path.name), path.open("rb") as file:
result = FormF3Parser(report_year=year).parse(file)
self.assertEqual(result.loaded_count, 20)
self.assertEqual(result.skipped_count, 0)
def test_form_f4_workbooks_match_current_schema(self):
for path in sorted(DEMO_DIR.glob("Ф-4_*.xlsx")):
match = re.search(r"_(\d{4})-H([12])", path.name)
year, half_year = map(int, match.groups())
with self.subTest(path=path.name), path.open("rb") as file:
result = FormF4Parser(
report_year=year,
report_half_year=half_year,
).parse(file)
self.assertEqual(result.loaded_count, 20)
self.assertEqual(result.skipped_count, 0)
def test_form_f6_workbooks_are_structurally_consistent(self):
for path in sorted(DEMO_DIR.glob("Ф-6_*.xlsx")):
year = int(re.search(r"_(\d{4})", path.name).group(1))
with self.subTest(path=path.name), path.open("rb") as file:
result = FormF6Parser(report_year=year).parse(file)
self.assertEqual(result.loaded_count, 20)
self.assertEqual(result.skipped_count, 0)

View File

@@ -59,6 +59,51 @@ class GenerateTestReportsCommandTest(TestCase):
self.assertEqual(PublicProcurement.objects.count(), 3)
self.assertEqual(ArbitrationCase.objects.count(), 3)
for record in FormF3Record.objects.all():
self.assertEqual(
sum(
(
record.employees_under_20,
record.employees_20_29,
record.employees_30_39,
record.employees_40_49,
record.employees_50_59,
record.employees_over_60,
)
),
int(record.avg_employees),
)
self.assertEqual(
record.machine_tools_and_equipment,
record.total_equipment,
)
for record in FormF6Record.objects.all():
self.assertEqual(
sum(
(
record.age_under_5,
record.age_5_10,
record.age_10_15,
record.age_15_20,
record.age_over_20,
)
),
record.total_equipment,
)
self.assertEqual(
sum(
(
record.age_under_5_imported,
record.age_5_10_imported,
record.age_10_15_imported,
record.age_15_20_imported,
record.age_over_20_imported,
)
),
record.imported_equipment,
)
self.assertIn(
"Ф-1: создано 12 записей, активных 9, архивных 3", stdout.getvalue()
)