feat: use authoritative organization directory
This commit is contained in:
@@ -22,9 +22,9 @@ from apps.parsers.services import (
|
||||
)
|
||||
from django.db import IntegrityError
|
||||
from django.test import TestCase
|
||||
from organizations.models import Organization
|
||||
|
||||
from tests.apps.parsers.factories import ParserLoadLogFactory
|
||||
from tests.apps.registers.factories import OrganizationFactory
|
||||
|
||||
|
||||
class NormalizeHelpersTest(TestCase):
|
||||
@@ -67,34 +67,38 @@ class RegistryOrganizationResolverTest(TestCase):
|
||||
self.assertEqual(lookup.by_ogrn, {})
|
||||
|
||||
def test_resolve_organization_id_by_unique_inn_and_ogrn(self):
|
||||
org_by_inn = OrganizationFactory(
|
||||
mn_inn=7_701_001_001, mn_ogrn=10_277_001_000_001
|
||||
org_by_inn = Organization.objects.create(
|
||||
name="By INN",
|
||||
inn="7701001001",
|
||||
ogrn="1027700100001",
|
||||
)
|
||||
org_by_ogrn = OrganizationFactory(
|
||||
mn_inn=7_701_001_002, mn_ogrn=10_277_001_000_002
|
||||
org_by_ogrn = Organization.objects.create(
|
||||
name="By OGRN",
|
||||
inn="7701001002",
|
||||
ogrn="1027700100002",
|
||||
)
|
||||
lookup = RegistryOrganizationResolver.build_lookup(
|
||||
[
|
||||
(org_by_inn.mn_inn, None),
|
||||
(None, org_by_ogrn.mn_ogrn),
|
||||
(org_by_inn.inn, None),
|
||||
(None, org_by_ogrn.ogrn),
|
||||
]
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
RegistryOrganizationResolver.resolve_organization_id(
|
||||
lookup=lookup,
|
||||
inn=str(org_by_inn.mn_inn),
|
||||
inn=org_by_inn.inn,
|
||||
ogrn=None,
|
||||
),
|
||||
org_by_inn.id,
|
||||
str(org_by_inn.uid),
|
||||
)
|
||||
self.assertEqual(
|
||||
RegistryOrganizationResolver.resolve_organization_id(
|
||||
lookup=lookup,
|
||||
inn=None,
|
||||
ogrn=str(org_by_ogrn.mn_ogrn),
|
||||
ogrn=org_by_ogrn.ogrn,
|
||||
),
|
||||
org_by_ogrn.id,
|
||||
str(org_by_ogrn.uid),
|
||||
)
|
||||
|
||||
|
||||
@@ -142,6 +146,17 @@ class ParserLoadLogServiceRetryTest(TestCase):
|
||||
|
||||
class SmallParserServiceQueryTest(TestCase):
|
||||
def test_industrial_product_service_query_helpers(self):
|
||||
Organization.objects.create(
|
||||
name='ООО "Продукт 1"',
|
||||
inn="7701001001",
|
||||
ogrn="1027700100001",
|
||||
)
|
||||
Organization.objects.create(
|
||||
name='ООО "Продукт 2"',
|
||||
inn="7701001001",
|
||||
ogrn="1027700100002",
|
||||
)
|
||||
|
||||
IndustrialProductService.save_products(
|
||||
[
|
||||
IndustrialProduct(
|
||||
@@ -186,6 +201,17 @@ class SmallParserServiceQueryTest(TestCase):
|
||||
)
|
||||
|
||||
def test_inspection_service_has_data_for_period(self):
|
||||
Organization.objects.create(
|
||||
name='ООО "Проверка 1"',
|
||||
inn="7701002001",
|
||||
ogrn="1027700200001",
|
||||
)
|
||||
Organization.objects.create(
|
||||
name='ООО "Проверка 2"',
|
||||
inn="7701002002",
|
||||
ogrn="1027700200002",
|
||||
)
|
||||
|
||||
InspectionService.save_inspections(
|
||||
[
|
||||
Inspection(
|
||||
@@ -237,6 +263,19 @@ class SmallParserServiceQueryTest(TestCase):
|
||||
self.assertTrue(InspectionService.has_data_for_period(2026, 4, True))
|
||||
|
||||
def test_procurement_service_find_by_customer_name_with_batch(self):
|
||||
Organization.objects.create(
|
||||
name="АО Тестовый заказчик 1",
|
||||
inn="7701003001",
|
||||
kpp="770101001",
|
||||
ogrn="1027700300001",
|
||||
)
|
||||
Organization.objects.create(
|
||||
name="АО Тестовый заказчик 2",
|
||||
inn="7701003002",
|
||||
kpp="770101002",
|
||||
ogrn="1027700300002",
|
||||
)
|
||||
|
||||
ProcurementService.save_procurements(
|
||||
[
|
||||
Procurement(
|
||||
@@ -293,6 +332,11 @@ class SmallParserServiceQueryTest(TestCase):
|
||||
|
||||
class FNSReportServiceHelpersTest(TestCase):
|
||||
def test_exists_find_and_status_helpers(self):
|
||||
Organization.objects.create(
|
||||
name='ООО "ФНС"',
|
||||
ogrn="1027700111111",
|
||||
)
|
||||
|
||||
report = FNSReportService.save_report(
|
||||
external_id="EXT-100",
|
||||
ogrn="1027700111111",
|
||||
|
||||
Reference in New Issue
Block a user