fix: keep test finance exchange identities stable
This commit is contained in:
@@ -293,12 +293,12 @@ class TestCompanyDatasetService:
|
|||||||
|
|
||||||
if source == ParserLoadLog.Source.FNS_REPORTS:
|
if source == ParserLoadLog.Source.FNS_REPORTS:
|
||||||
legacy_record, _ = FinancialReport.objects.update_or_create(
|
legacy_record, _ = FinancialReport.objects.update_or_create(
|
||||||
external_id=f"test-company-{index:02d}",
|
file_hash=payload["file_hash"],
|
||||||
defaults={
|
defaults={
|
||||||
**common,
|
**common,
|
||||||
|
"external_id": external_id,
|
||||||
"ogrn": organization.ogrn,
|
"ogrn": organization.ogrn,
|
||||||
"file_name": payload["file_name"],
|
"file_name": payload["file_name"],
|
||||||
"file_hash": payload["file_hash"],
|
|
||||||
"status": FinancialReport.Status.SUCCESS,
|
"status": FinancialReport.Status.SUCCESS,
|
||||||
"source": FinancialReport.SourceType.API,
|
"source": FinancialReport.SourceType.API,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ from organizations.models import (
|
|||||||
OrganizationSourceRecord,
|
OrganizationSourceRecord,
|
||||||
SourceGroup,
|
SourceGroup,
|
||||||
)
|
)
|
||||||
|
from organizations.test_companies import TEST_RECORD_PREFIX
|
||||||
|
|
||||||
TEST_EXCHANGE_TOKEN = "test-exchange-token" # noqa: S105
|
TEST_EXCHANGE_TOKEN = "test-exchange-token" # noqa: S105
|
||||||
|
|
||||||
@@ -104,6 +105,13 @@ class TestCompaniesCommandsTest(TestCase):
|
|||||||
self.assertEqual(InspectionRecord.objects.count(), 20)
|
self.assertEqual(InspectionRecord.objects.count(), 20)
|
||||||
self.assertEqual(ProcurementRecord.objects.count(), 20)
|
self.assertEqual(ProcurementRecord.objects.count(), 20)
|
||||||
self.assertEqual(FinancialReport.objects.count(), 20)
|
self.assertEqual(FinancialReport.objects.count(), 20)
|
||||||
|
self.assertEqual(
|
||||||
|
set(FinancialReport.objects.values_list("external_id", flat=True)),
|
||||||
|
{
|
||||||
|
f"{TEST_RECORD_PREFIX}:{index:02d}:{ParserLoadLog.Source.FNS_REPORTS}"
|
||||||
|
for index in range(1, 21)
|
||||||
|
},
|
||||||
|
)
|
||||||
self.assertEqual(FinancialReportLine.objects.count(), 20 * 4)
|
self.assertEqual(FinancialReportLine.objects.count(), 20 * 4)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
set(FinancialReportLine.objects.values_list("year", flat=True)),
|
set(FinancialReportLine.objects.values_list("year", flat=True)),
|
||||||
@@ -129,6 +137,11 @@ class TestCompaniesCommandsTest(TestCase):
|
|||||||
record.title = "Устаревшие тестовые данные"
|
record.title = "Устаревшие тестовые данные"
|
||||||
record.payload = {"stale": True}
|
record.payload = {"stale": True}
|
||||||
record.save(update_fields=["title", "payload"])
|
record.save(update_fields=["title", "payload"])
|
||||||
|
financial_report = FinancialReport.objects.get(
|
||||||
|
registry_organization=first_company
|
||||||
|
)
|
||||||
|
financial_report.external_id = "test-company-01"
|
||||||
|
financial_report.save(update_fields=["external_id"])
|
||||||
|
|
||||||
call_command("create_test_companies", stdout=StringIO())
|
call_command("create_test_companies", stdout=StringIO())
|
||||||
|
|
||||||
@@ -145,6 +158,11 @@ class TestCompaniesCommandsTest(TestCase):
|
|||||||
record.refresh_from_db()
|
record.refresh_from_db()
|
||||||
self.assertNotEqual(record.title, "Устаревшие тестовые данные")
|
self.assertNotEqual(record.title, "Устаревшие тестовые данные")
|
||||||
self.assertIn("registration_number", record.payload)
|
self.assertIn("registration_number", record.payload)
|
||||||
|
financial_report.refresh_from_db()
|
||||||
|
self.assertEqual(
|
||||||
|
financial_report.external_id,
|
||||||
|
f"{TEST_RECORD_PREFIX}:01:{ParserLoadLog.Source.FNS_REPORTS}",
|
||||||
|
)
|
||||||
self.assertEqual(OrganizationSourceRecord.objects.count(), 20 * 15)
|
self.assertEqual(OrganizationSourceRecord.objects.count(), 20 * 15)
|
||||||
|
|
||||||
@override_settings(STATE_CORP_EXCHANGE_TOKEN=TEST_EXCHANGE_TOKEN)
|
@override_settings(STATE_CORP_EXCHANGE_TOKEN=TEST_EXCHANGE_TOKEN)
|
||||||
|
|||||||
Reference in New Issue
Block a user