fix(organizations): reconcile stale demo source links
All checks were successful
CI/CD Pipeline / Quality Gate (push) Successful in 1m8s
CI/CD Pipeline / Build and Push Images (push) Successful in 31s
CI/CD Pipeline / Internal Notify (push) Successful in 0s
CI/CD Pipeline / Deploy Dev via Compose (push) Successful in 32s

This commit is contained in:
2026-08-10 14:32:04 +02:00
parent d079c74ecf
commit d03f38414a
2 changed files with 47 additions and 0 deletions

View File

@@ -216,6 +216,34 @@ class TestCompaniesCommandsTest(TestCase):
)
self.assertEqual(OrganizationSourceRecord.objects.count(), 20 * 15)
def test_create_replaces_stale_source_record_for_same_legacy_row(self):
call_command("create_test_companies", stdout=StringIO())
company = Organization.objects.get(name="Тестовая компания 1")
stale_record = OrganizationSourceRecord.objects.get(
extension__organization=company,
source=ParserLoadLog.Source.PROCUREMENTS,
)
stale_record.external_id = "0373200000000000001"
stale_record.save(update_fields=["external_id"])
call_command("create_test_companies", stdout=StringIO())
canonical_record = OrganizationSourceRecord.objects.get(
extension__organization=company,
source=ParserLoadLog.Source.PROCUREMENTS,
)
self.assertEqual(
canonical_record.external_id,
f"{TEST_RECORD_PREFIX}:01:{ParserLoadLog.Source.PROCUREMENTS}",
)
self.assertEqual(
canonical_record.legacy_pk,
str(
ProcurementRecord.objects.get(purchase_number="0373200000000000001").pk
),
)
@override_settings(STATE_CORP_EXCHANGE_TOKEN=TEST_EXCHANGE_TOKEN)
def test_created_source_records_are_included_in_state_corp_package(self):
call_command("create_test_companies", stdout=StringIO())