feat: expand registry ingestion and demo exchange
This commit is contained in:
@@ -13,6 +13,12 @@ from rest_framework.test import APITestCase
|
||||
from tests.apps.user.factories import UserFactory
|
||||
|
||||
|
||||
def create_frontend_organization(**kwargs):
|
||||
"""Create an organization visible through the frontend API by default."""
|
||||
kwargs.setdefault("opk_registry_membership", True)
|
||||
return Organization.objects.create(**kwargs)
|
||||
|
||||
|
||||
class OrganizationSourceExtensionsApiV2Test(APITestCase):
|
||||
"""Checks organization-centric source extension API contract."""
|
||||
|
||||
@@ -22,7 +28,7 @@ class OrganizationSourceExtensionsApiV2Test(APITestCase):
|
||||
self.client.force_authenticate(self.user)
|
||||
|
||||
def test_list_returns_compact_source_summaries_instead_of_embedded_data(self):
|
||||
organization = Organization.objects.create(
|
||||
organization = create_frontend_organization(
|
||||
name='ООО "API"',
|
||||
inn="7707083810",
|
||||
ogrn="1027700132010",
|
||||
@@ -56,7 +62,7 @@ class OrganizationSourceExtensionsApiV2Test(APITestCase):
|
||||
self.assertEqual(item["sources"][0]["records_count"], 1)
|
||||
|
||||
def test_organization_sources_action_returns_extensions(self):
|
||||
organization = Organization.objects.create(
|
||||
organization = create_frontend_organization(
|
||||
name='ООО "Sources"',
|
||||
inn="7707083811",
|
||||
ogrn="1027700132011",
|
||||
@@ -77,7 +83,7 @@ class OrganizationSourceExtensionsApiV2Test(APITestCase):
|
||||
self.assertEqual(response.data[0]["uid"], str(extension.uid))
|
||||
|
||||
def test_source_records_endpoint_returns_extension_records(self):
|
||||
organization = Organization.objects.create(
|
||||
organization = create_frontend_organization(
|
||||
name='ООО "Records"',
|
||||
inn="7707083812",
|
||||
ogrn="1027700132012",
|
||||
@@ -110,12 +116,12 @@ class OrganizationSourceExtensionsApiV2Test(APITestCase):
|
||||
)
|
||||
|
||||
def test_flat_source_records_endpoint_filters_by_source_group(self):
|
||||
target = Organization.objects.create(
|
||||
target = create_frontend_organization(
|
||||
name='ООО "Flat Records"',
|
||||
inn="7707083813",
|
||||
ogrn="1027700132013",
|
||||
)
|
||||
other = Organization.objects.create(
|
||||
other = create_frontend_organization(
|
||||
name='ООО "Other Records"',
|
||||
inn="7707083814",
|
||||
ogrn="1027700132014",
|
||||
@@ -160,18 +166,19 @@ class OrganizationSourceExtensionsApiV2Test(APITestCase):
|
||||
self.assertEqual(record["source_group"], "planned_inspections")
|
||||
self.assertEqual(record["organization"]["uid"], str(target.uid))
|
||||
|
||||
def test_flat_source_records_endpoint_filters_by_has_registry(self):
|
||||
with_registry = Organization.objects.create(
|
||||
def test_flat_source_records_scope_cannot_be_lifted_by_has_registry(self):
|
||||
with_registry = create_frontend_organization(
|
||||
name='ООО "With Registry Source"',
|
||||
inn="7707083815",
|
||||
ogrn="1027700132015",
|
||||
opk_registry_membership=True,
|
||||
ropk_razdel_num="source-records",
|
||||
)
|
||||
without_registry = Organization.objects.create(
|
||||
without_registry = create_frontend_organization(
|
||||
name='ООО "Without Registry Source"',
|
||||
inn="7707083816",
|
||||
ogrn="1027700132016",
|
||||
opk_registry_membership=False,
|
||||
)
|
||||
with_registry_extension = PlannedInspectionExtension.objects.create(
|
||||
organization=with_registry,
|
||||
@@ -225,11 +232,11 @@ class OrganizationSourceExtensionsApiV2Test(APITestCase):
|
||||
)
|
||||
self.assertEqual(
|
||||
without_registry_response.data["data"][0]["external_id"],
|
||||
"INSP-WITHOUT-REGISTRY",
|
||||
"INSP-WITH-REGISTRY",
|
||||
)
|
||||
|
||||
def test_source_record_organization_uses_active_registry_identity(self):
|
||||
organization = Organization.objects.create(
|
||||
organization = create_frontend_organization(
|
||||
name='ООО "Реестровое имя"',
|
||||
inn="1800020960",
|
||||
kpp="180001001",
|
||||
@@ -266,7 +273,7 @@ class OrganizationSourceExtensionsApiV2Test(APITestCase):
|
||||
self.assertEqual(response_organization["ogrn"], organization.ogrn)
|
||||
|
||||
def test_source_record_organization_keeps_canonical_inn_with_leading_zero(self):
|
||||
organization = Organization.objects.create(
|
||||
organization = create_frontend_organization(
|
||||
name='ООО "Башнефть-Добыча"',
|
||||
inn="0277106840",
|
||||
ogrn="1090280032699",
|
||||
@@ -298,12 +305,12 @@ class OrganizationSourceExtensionsApiV2Test(APITestCase):
|
||||
self.assertEqual(response_organization["ogrn"], organization.ogrn)
|
||||
|
||||
def test_flat_source_records_searches_payload_values_displayed_in_tables(self):
|
||||
target = Organization.objects.create(
|
||||
target = create_frontend_organization(
|
||||
name='ООО "Поиск по payload"',
|
||||
inn="7707083817",
|
||||
ogrn="1027700132017",
|
||||
)
|
||||
other = Organization.objects.create(
|
||||
other = create_frontend_organization(
|
||||
name='ООО "Другая payload"',
|
||||
inn="7707083818",
|
||||
ogrn="1027700132018",
|
||||
@@ -363,7 +370,7 @@ class OrganizationSourceExtensionsApiV2Test(APITestCase):
|
||||
)
|
||||
|
||||
def test_flat_source_records_searches_registry_identity_displayed_in_tables(self):
|
||||
organization = Organization.objects.create(
|
||||
organization = create_frontend_organization(
|
||||
name='АО "Реестровый поиск"',
|
||||
inn="1800020961",
|
||||
kpp="180001002",
|
||||
|
||||
Reference in New Issue
Block a user