feat: import exchange registry memberships
All checks were successful
CI/CD Pipeline / Code Quality Checks (push) Successful in 2m47s
CI/CD Pipeline / Run Tests (push) Successful in 2m49s
CI/CD Pipeline / Build Docker Images (push) Successful in 41s
CI/CD Pipeline / Push to Gitea Registry (push) Successful in 1s
CI/CD Pipeline / Deploy to Server (push) Successful in 1s

This commit is contained in:
2026-05-28 12:11:53 +02:00
parent d1b0cd7945
commit e09002d3af
2 changed files with 300 additions and 3 deletions

View File

@@ -29,6 +29,7 @@ from apps.external_data.models import (
PublicProcurement,
)
from apps.organization.models import Organization
from apps.registers.models import RegisterUpload, RegistryMembershipPeriod
from apps.user.models import User
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from django.conf import settings
@@ -168,6 +169,20 @@ def build_exchange_payload() -> dict[str, list[dict[str, object]]]:
"registry_number": "prod-001",
}
],
"registry_memberships": [
{
"organization_inn": "7707083893",
"registry_name": "Реестр госкорпорации Росатом",
"started_at": "2026-01-01",
"ended_at": None,
},
{
"organization_inn": "7707083894",
"registry_name": "Реестр госкорпорации Роскосмос",
"started_at": "2026-02-01",
"ended_at": None,
},
],
"industrial_certificates": [
{
"organization_inn": "7707083893",
@@ -326,7 +341,13 @@ class ExchangePackageApiTest(APITestCase):
self.assertFalse(response.data["result"]["duplicate"])
self.assertEqual(response.data["result"]["organizations"]["created"], 1)
self.assertEqual(response.data["result"]["organizations"]["updated"], 1)
self.assertEqual(
response.data["result"]["registry_memberships"]["opened"],
2,
)
self.assertEqual(Organization.objects.count(), 2)
self.assertEqual(RegisterUpload.objects.count(), 2)
self.assertEqual(RegistryMembershipPeriod.objects.count(), 2)
self.assertEqual(IndustrialCertificate.objects.count(), 1)
self.assertEqual(ManufacturerRegistryEntry.objects.count(), 1)
self.assertEqual(IndustrialProduct.objects.count(), 1)
@@ -366,6 +387,10 @@ class ExchangePackageApiTest(APITestCase):
self.assertEqual(organization.executors_count, 175)
self.assertTrue(organization.tax_reports_available)
self.assertTrue(organization.in_275_fz_registry)
self.assertEqual(
organization.get_active_registry_names(),
["Реестр госкорпорации Росатом"],
)
package_import = ExchangePackageImport.objects.get()
self.assertEqual(package_import.delivery_channel, ExchangeDeliveryChannel.API)