Merge remote-tracking branch 'origin/main' into dev
All checks were successful
CI/CD Pipeline / Quality Gate (push) Successful in 33s
CI/CD Pipeline / Build and Push Images (push) Successful in 18s
CI/CD Pipeline / Internal Notify (push) Successful in 0s
CI/CD Pipeline / Deploy Dev via Compose (push) Successful in 24s

# Conflicts:
#	tests/apps/exchange/test_state_corp_services.py
This commit is contained in:
2026-07-22 17:27:04 +02:00
9 changed files with 439 additions and 48 deletions

View File

@@ -32,7 +32,6 @@ from apps.parsers.services import (
)
from django.test import TestCase
from organizations.models import (
Organization,
OrganizationSourceFinancialLine,
OrganizationSourceRecord,
)
@@ -62,7 +61,9 @@ class DirectIngestionParserServicesTest(TestCase):
okpo="",
)
def test_industrial_certificate_save_records_writes_organization_source_records(self):
def test_industrial_certificate_save_records_writes_organization_source_records(
self,
):
saved = IndustrialCertificateService.save_certificates(
[
IndustrialCertificate(
@@ -89,7 +90,9 @@ class DirectIngestionParserServicesTest(TestCase):
self.assertEqual(record.payload["expiry_date_normalized"], "2029-02-01")
self.assertEqual(record.url, "https://example.test/cert.pdf")
def test_industrial_certificate_save_records_skips_records_without_certificate_number(self):
def test_industrial_certificate_save_records_skips_records_without_certificate_number(
self,
):
saved = IndustrialCertificateService.save_certificates(
[
IndustrialCertificate(
@@ -255,6 +258,39 @@ class DirectIngestionParserServicesTest(TestCase):
self.assertEqual(record.payload["registry"], "fas")
self.assertEqual(record.load_batch, 51)
def test_vacancy_and_arbitration_dates_are_normalized_for_source_records(self):
for index, (source, raw_date, expected_date) in enumerate(
(
(ParserLoadLog.Source.TRUDVSEM, "04.12.2025", "2025-12-04"),
(ParserLoadLog.Source.ARBITRATION, "14.07.2026", "2026-07-14"),
),
start=1,
):
external_id = f"canonical-date-{index}"
saved = GenericParserRecordService.save_records(
[
GenericParserItem(
source=source,
external_id=external_id,
inn="7707083803",
ogrn="",
organisation_name='ООО "Каноническая дата"',
title="Запись с датой",
record_date=raw_date,
)
],
batch_id=60 + index,
source=source,
)
self.assertEqual(saved, 1)
record = OrganizationSourceRecord.objects.get(
source=source,
external_id=external_id,
)
self.assertEqual(record.record_date, expected_date)
self.assertEqual(record.payload["record_date"], expected_date)
def test_inspection_save_records_writes_organization_source_records(self):
saved = InspectionService.save_inspections(
[
@@ -285,6 +321,7 @@ class DirectIngestionParserServicesTest(TestCase):
external_id="INSP-DIRECT-1",
)
self.assertEqual(record.record_type, "inspection")
self.assertEqual(record.record_date, "2026-03-01")
self.assertEqual(record.payload["control_authority"], "Контроль")
self.assertEqual(record.payload["start_date_normalized"], "2026-03-01")
self.assertEqual(record.payload["data_year"], 2026)