fix(organizations): reconcile stale demo source links
All checks were successful
All checks were successful
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user