feat: address QA feedback and limit Checko collection
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
from decimal import Decimal
|
||||
from tempfile import NamedTemporaryFile
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.test import TestCase
|
||||
from openpyxl import Workbook
|
||||
@@ -61,6 +62,19 @@ class OrganizationDirectoryImportServiceTest(TestCase):
|
||||
self.assertTrue(organization.goz_participation)
|
||||
self.assertFalse(organization.opk_registry_membership)
|
||||
|
||||
def test_import_xlsx_invalidates_organization_api_cache_after_commit(self):
|
||||
path = self._workbook_path([self._row(rn="10")])
|
||||
|
||||
with (
|
||||
patch(
|
||||
"organizations.directory_import.invalidate_organization_api_cache"
|
||||
) as invalidate_cache,
|
||||
self.captureOnCommitCallbacks(execute=True),
|
||||
):
|
||||
OrganizationDirectoryImportService.import_xlsx(path)
|
||||
|
||||
invalidate_cache.assert_called_once_with()
|
||||
|
||||
def test_import_xlsx_rejects_missing_required_column(self):
|
||||
path = self._workbook_path([], headers=SOURCE_HEADERS[:-1])
|
||||
|
||||
@@ -111,9 +125,7 @@ class OrganizationDirectoryImportServiceTest(TestCase):
|
||||
]
|
||||
embedded_value = "\t".join(str(value or "") for value in first_tail)
|
||||
embedded_value = (
|
||||
embedded_value
|
||||
+ "_x000D_\n"
|
||||
+ "\t".join(["21", "0", "0", 'ООО "Вторая"'])
|
||||
embedded_value + "_x000D_\n" + "\t".join(["21", "0", "0", 'ООО "Вторая"'])
|
||||
)
|
||||
|
||||
second_row = self._row(
|
||||
|
||||
@@ -3,7 +3,16 @@
|
||||
from io import StringIO
|
||||
|
||||
from apps.exchange.state_corp_services import StateCorpExchangeService
|
||||
from apps.parsers.models import ParserLoadLog
|
||||
from apps.parsers.models import (
|
||||
FinancialReport,
|
||||
GenericParserRecord,
|
||||
IndustrialCertificateRecord,
|
||||
IndustrialProductRecord,
|
||||
InspectionRecord,
|
||||
ManufacturerRecord,
|
||||
ParserLoadLog,
|
||||
ProcurementRecord,
|
||||
)
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase, override_settings
|
||||
from organizations.models import (
|
||||
@@ -79,6 +88,13 @@ class TestCompaniesCommandsTest(TestCase):
|
||||
).count(),
|
||||
20 * 4,
|
||||
)
|
||||
self.assertEqual(IndustrialCertificateRecord.objects.count(), 20)
|
||||
self.assertEqual(IndustrialProductRecord.objects.count(), 20)
|
||||
self.assertEqual(ManufacturerRecord.objects.count(), 20)
|
||||
self.assertEqual(InspectionRecord.objects.count(), 20)
|
||||
self.assertEqual(ProcurementRecord.objects.count(), 20)
|
||||
self.assertEqual(FinancialReport.objects.count(), 20)
|
||||
self.assertEqual(GenericParserRecord.objects.count(), 20 * 9)
|
||||
|
||||
def test_create_updates_the_fixed_dataset_without_duplicates(self):
|
||||
call_command("create_test_companies", stdout=StringIO())
|
||||
@@ -125,9 +141,7 @@ class TestCompaniesCommandsTest(TestCase):
|
||||
.order_by("rn")
|
||||
.values_list("inn", flat=True)
|
||||
)
|
||||
package = StateCorpExchangeService.build_package(
|
||||
organization_inns=company_inns
|
||||
)
|
||||
package = StateCorpExchangeService.build_package(organization_inns=company_inns)
|
||||
|
||||
self.assertEqual(
|
||||
package.payload_counts,
|
||||
@@ -137,7 +151,7 @@ class TestCompaniesCommandsTest(TestCase):
|
||||
"manufacturers": 20,
|
||||
"industrial_products": 20,
|
||||
"prosecutor_checks": 20,
|
||||
"public_procurements": 80,
|
||||
"public_procurements": 60,
|
||||
"financial_reports": 20,
|
||||
"arbitration_cases": 20,
|
||||
"bankruptcy_procedures": 20,
|
||||
@@ -166,3 +180,6 @@ class TestCompaniesCommandsTest(TestCase):
|
||||
self.assertTrue(Organization.objects.filter(uid=untouched.uid).exists())
|
||||
self.assertEqual(OrganizationSourceExtension.objects.count(), 0)
|
||||
self.assertEqual(OrganizationSourceRecord.objects.count(), 0)
|
||||
self.assertEqual(GenericParserRecord.objects.count(), 0)
|
||||
self.assertEqual(IndustrialProductRecord.objects.count(), 0)
|
||||
self.assertEqual(FinancialReport.objects.count(), 0)
|
||||
|
||||
Reference in New Issue
Block a user