fix: resolve parser organizations from directory only
This commit is contained in:
@@ -4,6 +4,7 @@ from decimal import Decimal
|
||||
|
||||
from apps.parsers.models import FinancialReport, GenericParserRecord, ParserLoadLog
|
||||
from django.test import TestCase
|
||||
from django.utils import timezone
|
||||
from organizations.models import (
|
||||
DefenseSupplierExtension,
|
||||
FinancialIndicatorsExtension,
|
||||
@@ -22,8 +23,13 @@ from organizations.source_ingestion import (
|
||||
class OrganizationSourceIngestionServiceTest(TestCase):
|
||||
"""Checks runtime parser writes bypass legacy parser record tables."""
|
||||
|
||||
@staticmethod
|
||||
def _directory_organization(**kwargs) -> Organization:
|
||||
kwargs.setdefault("directory_imported_at", timezone.now())
|
||||
return Organization.objects.create(**kwargs)
|
||||
|
||||
def test_save_generic_records_writes_source_records_without_legacy_rows(self):
|
||||
Organization.objects.create(
|
||||
self._directory_organization(
|
||||
name='ООО "ГОЗ"',
|
||||
inn="7707083803",
|
||||
)
|
||||
@@ -70,7 +76,7 @@ class OrganizationSourceIngestionServiceTest(TestCase):
|
||||
self.assertEqual(record.legacy_pk, "")
|
||||
|
||||
def test_save_records_is_idempotent_by_source_external_id(self):
|
||||
Organization.objects.create(
|
||||
self._directory_organization(
|
||||
name='ООО "Идемпотентность"',
|
||||
inn="7707083810",
|
||||
)
|
||||
@@ -140,7 +146,7 @@ class OrganizationSourceIngestionServiceTest(TestCase):
|
||||
self.assertFalse(name_only.source_extensions.exists())
|
||||
|
||||
def test_save_records_does_not_fill_missing_identity_on_resolved_organization(self):
|
||||
partial = Organization.objects.create(
|
||||
partial = self._directory_organization(
|
||||
name="Acme Security",
|
||||
inn="7713497980",
|
||||
ogrn="1237700253306",
|
||||
@@ -168,14 +174,14 @@ class OrganizationSourceIngestionServiceTest(TestCase):
|
||||
self.assertEqual(record.extension.organization, partial)
|
||||
|
||||
def test_save_records_uses_single_head_organization_for_duplicate_inn_ogrn(self):
|
||||
head = Organization.objects.create(
|
||||
head = self._directory_organization(
|
||||
name="Head",
|
||||
inn="7713497980",
|
||||
ogrn="1237700253306",
|
||||
filial=".F.",
|
||||
is_branch=False,
|
||||
)
|
||||
Organization.objects.create(
|
||||
self._directory_organization(
|
||||
name="Branch",
|
||||
inn="7713497980",
|
||||
ogrn="1237700253306",
|
||||
@@ -202,14 +208,14 @@ class OrganizationSourceIngestionServiceTest(TestCase):
|
||||
self.assertEqual(record.extension.organization, head)
|
||||
|
||||
def test_save_records_skips_ambiguous_duplicate_inn_ogrn(self):
|
||||
Organization.objects.create(
|
||||
self._directory_organization(
|
||||
name="Head 1",
|
||||
inn="7713497980",
|
||||
ogrn="1237700253306",
|
||||
filial=".F.",
|
||||
is_branch=False,
|
||||
)
|
||||
Organization.objects.create(
|
||||
self._directory_organization(
|
||||
name="Head 2",
|
||||
inn="7713497980",
|
||||
ogrn="1237700253306",
|
||||
@@ -259,7 +265,7 @@ class OrganizationSourceIngestionServiceTest(TestCase):
|
||||
self.assertFalse(Organization.objects.filter(inn="7720525156").exists())
|
||||
|
||||
def test_save_records_does_not_add_ogrip_to_existing_legal_entity(self):
|
||||
organization = Organization.objects.create(
|
||||
organization = self._directory_organization(
|
||||
name='ООО "Металл-Завод"',
|
||||
inn="7720525156",
|
||||
ogrn="1057746645395",
|
||||
@@ -286,7 +292,7 @@ class OrganizationSourceIngestionServiceTest(TestCase):
|
||||
self.assertEqual(organization.ogrip, "")
|
||||
|
||||
def test_save_financial_report_writes_financial_lines_without_legacy_report(self):
|
||||
Organization.objects.create(
|
||||
self._directory_organization(
|
||||
name='ООО "Финансовый отчет"',
|
||||
ogrn="1027700132002",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user