feat: import mostovik exchange sections
All checks were successful
CI/CD Pipeline / Run Tests (push) Successful in 6m12s
CI/CD Pipeline / Code Quality Checks (push) Successful in 6m19s
CI/CD Pipeline / Build Docker Images (push) Successful in 2m21s
CI/CD Pipeline / Push to Gitea Registry (push) Successful in 1s
CI/CD Pipeline / Deploy to Server (push) Successful in 1s

This commit is contained in:
2026-05-27 23:13:40 +02:00
parent bd8e1a8400
commit d1b0cd7945
49 changed files with 1831 additions and 319 deletions

View File

@@ -18,7 +18,8 @@ class FormF1RecordFactory(factory.django.DjangoModelFactory):
organization = factory.SubFactory(OrganizationFactory)
load_batch = factory.Sequence(lambda n: n + 1)
report_year = 2026
report_quarter = 1
report_month = 1
report_quarter = None
# Выпуск военной продукции (факт. цены)
military_output_actual = factory.LazyAttribute(

View File

@@ -53,14 +53,16 @@ class FormF1ServiceTest(TestCase):
organization=org,
load_batch=501,
report_year=2026,
report_quarter=1,
report_month=9,
report_quarter=None,
)
current = FormF1Service.create_versioned_record(
organization=org,
load_batch=502,
report_year=2026,
report_quarter=1,
report_quarter=None,
extra_period_fields={"report_month": 9},
military_output_actual=150,
)
@@ -69,6 +71,8 @@ class FormF1ServiceTest(TestCase):
self.assertEqual(previous.superseded_by_batch, 502)
self.assertIsNotNone(previous.superseded_at)
self.assertTrue(current.is_active_version)
self.assertEqual(current.report_month, 9)
self.assertIsNone(current.report_quarter)
class FormF1ParserTest(TestCase):
@@ -76,7 +80,7 @@ class FormF1ParserTest(TestCase):
def test_get_column_mappings_returns_mappings(self):
"""Test get_column_mappings returns correct mappings."""
parser = FormF1Parser(report_year=2026, report_quarter=1)
parser = FormF1Parser(report_year=2026, report_month=9)
mappings = parser.get_column_mappings()
self.assertIsInstance(mappings, list)
@@ -87,10 +91,11 @@ class FormF1ParserTest(TestCase):
self.assertIn("military_output_actual", field_names)
self.assertIn("civilian_output_actual", field_names)
def test_create_record_creates_organization(self):
"""Test create_record creates organization if not exists."""
parser = FormF1Parser(report_year=2026, report_quarter=1)
def test_create_record_uses_existing_organization(self):
"""Report imports must attach rows only to preloaded Mostovik organizations."""
parser = FormF1Parser(report_year=2026, report_month=9)
parser.load_batch = 505
organization = OrganizationFactory.create(inn="1234567890")
row_data = {
"inn": "1234567890",
@@ -103,7 +108,9 @@ class FormF1ParserTest(TestCase):
record = parser.create_record(row_data)
self.assertIsNotNone(record)
self.assertEqual(record.organization.inn, "1234567890")
self.assertEqual(record.organization_id, organization.id)
self.assertEqual(record.military_output_actual, 100.0)
self.assertEqual(record.report_year, 2026)
self.assertEqual(record.report_quarter, 1)
self.assertEqual(record.report_month, 9)
self.assertIsNone(record.report_quarter)
self.assertEqual(record.report_period_display, "Сентябрь 2026")