feat: complete published registry contracts and gated SRO ingestion
All checks were successful
Mostovik Backend CI/CD / Tests and lint (push) Successful in 3m55s
Mostovik Backend CI/CD / Build linux/amd64 release images (push) Successful in 3m43s
Mostovik Backend CI/CD / Deploy and verify internal main (push) Has been skipped
Mostovik Backend CI/CD / Deploy customer main (push) Has been skipped
Mostovik Backend CI/CD / Deploy dev (push) Successful in 1m45s
All checks were successful
Mostovik Backend CI/CD / Tests and lint (push) Successful in 3m55s
Mostovik Backend CI/CD / Build linux/amd64 release images (push) Successful in 3m43s
Mostovik Backend CI/CD / Deploy and verify internal main (push) Has been skipped
Mostovik Backend CI/CD / Deploy customer main (push) Has been skipped
Mostovik Backend CI/CD / Deploy dev (push) Successful in 1m45s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Tests for deterministic frontend demo company management commands."""
|
||||
|
||||
from io import StringIO
|
||||
from unittest.mock import patch
|
||||
|
||||
from apps.exchange.state_corp_services import StateCorpExchangeService
|
||||
from apps.parsers.models import (
|
||||
@@ -39,7 +40,9 @@ class TestCompaniesCommandsTest(TestCase):
|
||||
"""Checks creation, refresh, and removal of the fixed demo dataset."""
|
||||
|
||||
def test_create_builds_twenty_companies_with_every_source_dataset(self):
|
||||
call_command("create_test_companies", stdout=StringIO())
|
||||
with patch("apps.parsers.sro_membership.SroHttpClient") as sro_http:
|
||||
call_command("create_test_companies", stdout=StringIO())
|
||||
sro_http.assert_not_called()
|
||||
|
||||
companies = Organization.objects.filter(name__startswith="Тестовая компания ")
|
||||
self.assertEqual(companies.count(), 20)
|
||||
@@ -141,13 +144,14 @@ class TestCompaniesCommandsTest(TestCase):
|
||||
snapshot_sources = (
|
||||
ParserLoadLog.Source.FNS_SME_SUPPORT_RECIPIENTS,
|
||||
ParserLoadLog.Source.BUDGET_UBPANDNUBP,
|
||||
ParserLoadLog.Source.SRO_MEMBERSHIP_CHECK,
|
||||
)
|
||||
snapshot_records = OrganizationSourceRecord.objects.filter(
|
||||
source__in=snapshot_sources,
|
||||
)
|
||||
self.assertEqual(snapshot_records.count(), 40)
|
||||
self.assertEqual(snapshot_records.count(), 60)
|
||||
self.assertEqual(
|
||||
snapshot_records.filter(legacy_model="", legacy_pk="").count(), 40
|
||||
snapshot_records.filter(legacy_model="", legacy_pk="").count(), 60
|
||||
)
|
||||
self.assertFalse(
|
||||
GenericParserRecord.objects.filter(source__in=snapshot_sources).exists()
|
||||
@@ -165,6 +169,19 @@ class TestCompaniesCommandsTest(TestCase):
|
||||
self.assertEqual(
|
||||
budget.payload["upstream"]["info"]["inn"], budget.extension.organization.inn
|
||||
)
|
||||
from organizations.sro_payload_serializers import (
|
||||
SroMembershipDetailPayloadSerializer,
|
||||
)
|
||||
|
||||
sro_records = snapshot_records.filter(source=snapshot_sources[2])
|
||||
self.assertEqual(sro_records.count(), 20)
|
||||
self.assertEqual(
|
||||
set(sro_records.values_list("status", flat=True)), {"active", "inactive"}
|
||||
)
|
||||
for record in sro_records:
|
||||
self.assertEqual(record.record_type, "sro_membership")
|
||||
serializer = SroMembershipDetailPayloadSerializer(data=record.payload)
|
||||
self.assertTrue(serializer.is_valid(), serializer.errors)
|
||||
|
||||
def test_create_updates_the_fixed_dataset_without_duplicates(self):
|
||||
call_command("create_test_companies", stdout=StringIO())
|
||||
@@ -245,7 +262,10 @@ class TestCompaniesCommandsTest(TestCase):
|
||||
year=stale_year,
|
||||
).exists()
|
||||
)
|
||||
self.assertEqual(OrganizationSourceRecord.objects.count(), 20 * 19)
|
||||
self.assertEqual(
|
||||
OrganizationSourceRecord.objects.count(),
|
||||
20 * (len(ParserLoadLog.Source) - 1),
|
||||
)
|
||||
|
||||
def test_create_replaces_stale_source_record_for_same_legacy_row(self):
|
||||
call_command("create_test_companies", stdout=StringIO())
|
||||
|
||||
Reference in New Issue
Block a user