fix: resolve parser organizations from directory only
Some checks failed
CI/CD Pipeline / Quality Gate (push) Failing after 32s
CI/CD Pipeline / Build and Push Images (push) Has been skipped
CI/CD Pipeline / Internal Notify (push) Successful in 0s
CI/CD Pipeline / Deploy Dev via Compose (push) Has been skipped

This commit is contained in:
2026-06-07 16:28:57 +02:00
parent 6ba8fa8d88
commit 802257a757
19 changed files with 184 additions and 83 deletions

View File

@@ -8,6 +8,7 @@ from apps.parsers.models import (
)
from django.core.management import call_command
from django.test import TestCase
from django.utils import timezone
from organizations.models import (
DefenseSupplierExtension,
FinancialIndicatorsExtension,
@@ -28,8 +29,13 @@ from tests.apps.parsers.factories import (
class OrganizationSourceBackfillServiceTest(TestCase):
"""Checks idempotent migration from legacy source records."""
@staticmethod
def _directory_organization(**kwargs) -> Organization:
kwargs.setdefault("directory_imported_at", timezone.now())
return Organization.objects.create(**kwargs)
def test_backfills_inspection_records_into_planned_inspection_extension(self):
organization = Organization.objects.create(
organization = self._directory_organization(
name='ООО "Проверка"',
inn="7707083801",
ogrn="1027700132001",
@@ -71,7 +77,7 @@ class OrganizationSourceBackfillServiceTest(TestCase):
self.assertEqual(OrganizationSourceRecord.objects.count(), 1)
def test_backfill_payload_serializes_registry_organization_fk_as_id(self):
organization = Organization.objects.create(
organization = self._directory_organization(
name='ООО "FK Payload"',
inn="7707083815",
ogrn="1027700132015",
@@ -94,7 +100,7 @@ class OrganizationSourceBackfillServiceTest(TestCase):
self.assertEqual(record.payload["registry_organization"], str(organization.pk))
def test_backfills_financial_report_lines(self):
organization = Organization.objects.create(
organization = self._directory_organization(
name='ООО "Финансы"',
inn="7707083802",
ogrn="1027700132002",
@@ -132,7 +138,7 @@ class OrganizationSourceBackfillServiceTest(TestCase):
self.assertEqual(record.financial_lines.get().period_end, 200)
def test_backfills_generic_defense_supplier_records(self):
organization = Organization.objects.create(
organization = self._directory_organization(
name='ООО "ГОЗ"',
inn="7707083803",
)
@@ -189,7 +195,7 @@ class OrganizationSourceBackfillServiceTest(TestCase):
)
def test_management_command_runs_source_backfill(self):
organization = Organization.objects.create(
organization = self._directory_organization(
name='ООО "Команда"',
inn="7707083804",
ogrn="1027700132004",