3 Commits

Author SHA1 Message Date
ed2c6671b7 test: align demo company exchange expectations
All checks were successful
CI/CD Pipeline / Quality Gate (push) Successful in 29s
CI/CD Pipeline / Build and Push Images (push) Successful in 0s
CI/CD Pipeline / Internal Notify (push) Successful in 0s
CI/CD Pipeline / Deploy Dev via Compose (push) Successful in 1s
CI/CD Pipeline / Quality Gate (pull_request) Successful in 24s
CI/CD Pipeline / Build and Push Images (pull_request) Successful in 0s
CI/CD Pipeline / Internal Notify (pull_request) Successful in 0s
CI/CD Pipeline / Deploy Dev via Compose (pull_request) Successful in 0s
2026-07-22 14:33:14 +02:00
bd6f505091 fix: exclude demo companies from state corp exchange 2026-07-22 14:27:38 +02:00
avm
58d5b27454 Merge pull request 'Merge dev into main for customer release' (#33) from feature/customer-release-20260719 into main
Some checks failed
CI/CD Pipeline / Quality Gate (push) Successful in 30s
Deploy Customer Main / Build, Push, Deploy (push) Failing after 1s
CI/CD Pipeline / Build and Push Images (push) Successful in 1s
CI/CD Pipeline / Internal Notify (push) Successful in 1s
CI/CD Pipeline / Deploy Dev via Compose (push) Successful in 1s
2026-07-19 21:37:47 +03:00
3 changed files with 42 additions and 14 deletions

View File

@@ -35,6 +35,7 @@ from django.conf import settings
from django.db.models import Q
from django.utils import timezone
from organizations.models import Organization, OrganizationSourceRecord
from organizations.test_companies import TestCompanyDatasetService
class StateCorpExchangeError(ValueError):
@@ -289,7 +290,9 @@ class StateCorpExchangeService:
@classmethod
def _rosatom_roscosmos_queryset(cls):
queryset = Organization.objects.exclude(inn="")
queryset = Organization.objects.exclude(inn="").exclude(
uid__in=TestCompanyDatasetService.company_uids()
)
name_query = Q()
for keyword in cls.ROSATOM_ROSCOSMOS_GK_NAME_KEYWORDS:
name_query |= Q(gk_name__icontains=keyword)

View File

@@ -23,6 +23,7 @@ from apps.parsers.models import (
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from django.test import TestCase, override_settings
from organizations.models import Organization
from organizations.test_companies import TestCompanyDatasetService
from tests.apps.parsers.factories import (
IndustrialCertificateRecordFactory,
@@ -67,6 +68,30 @@ TEST_STATE_CORP_TOKEN = "state-corp-test-exchange-token" # noqa: S105
class StateCorpExchangeServiceTest(TestCase):
"""Verify package compatibility with state-corp receiver contract."""
def test_default_package_excludes_deterministic_test_companies(self):
real_organization = Organization.objects.create(
rn=1001,
name="Реальная организация",
inn="7707083893",
gk_name="Росатом",
)
Organization.objects.create(
uid=TestCompanyDatasetService.company_uids()[0],
rn=9001,
name="Тестовая компания 1",
inn="7700000001",
gk_name="Росатом",
)
package = StateCorpExchangeService.build_package()
payload = _decode_package_payload(package)
self.assertEqual(package.payload_counts["organizations"], 1)
self.assertEqual(
[row["mostovik_uid"] for row in payload["data"]["organizations"]],
[str(real_organization.uid)],
)
def test_build_package_contains_expected_payload(self):
organization = Organization.objects.create(
rn=1001,

View File

@@ -133,7 +133,7 @@ class TestCompaniesCommandsTest(TestCase):
self.assertEqual(OrganizationSourceRecord.objects.count(), 20 * 15)
@override_settings(STATE_CORP_EXCHANGE_TOKEN=TEST_EXCHANGE_TOKEN)
def test_created_source_records_are_exported_to_state_corp_package(self):
def test_created_source_records_are_excluded_from_state_corp_package(self):
call_command("create_test_companies", stdout=StringIO())
company_inns = list(
@@ -146,18 +146,18 @@ class TestCompaniesCommandsTest(TestCase):
self.assertEqual(
package.payload_counts,
{
"organizations": 20,
"industrial_certificates": 20,
"manufacturers": 20,
"industrial_products": 20,
"prosecutor_checks": 20,
"public_procurements": 60,
"financial_reports": 20,
"arbitration_cases": 20,
"bankruptcy_procedures": 20,
"defense_unreliable_suppliers": 40,
"information_security_registries": 20,
"labor_vacancies": 20,
"organizations": 0,
"industrial_certificates": 0,
"manufacturers": 0,
"industrial_products": 0,
"prosecutor_checks": 0,
"public_procurements": 0,
"financial_reports": 0,
"arbitration_cases": 0,
"bankruptcy_procedures": 0,
"defense_unreliable_suppliers": 0,
"information_security_registries": 0,
"labor_vacancies": 0,
},
)