feat: add Fedresurs profiles and integrated structures sources
Some checks failed
Mostovik Backend CI/CD / Tests and lint (push) Failing after 6m35s
Mostovik Backend CI/CD / Build linux/amd64 release images (push) Has been skipped
Mostovik Backend CI/CD / Deploy dev (push) Has been skipped
Mostovik Backend CI/CD / Deploy and verify internal main (push) Has been skipped

This commit is contained in:
Aleksandr Meshchryakov
2026-09-24 14:14:01 +02:00
parent 4c869b856c
commit 85a3c0650e
42 changed files with 3166 additions and 49 deletions

View File

@@ -210,7 +210,7 @@ def test_sro_export_keeps_all_years_and_identifier_strings(export_client, file_f
record_date="2001-01-01",
)
generation = exports.build_source_record_export_artifacts()
assert generation.artifacts_count == 43
assert generation.artifacts_count == 49
response = issue(export_client, "sro_membership", file_format)
assert response.status_code == 201
package = exports.consume_source_record_export_download_ticket(

View File

@@ -1,5 +1,6 @@
"""Tests for organization source-record ZIP export."""
import base64
import csv
import json
import os
@@ -28,6 +29,7 @@ from organizations.models import (
from organizations.source_record_export import (
SourceRecordExportArtifactsUnavailable,
_render_source_group_artifact,
_render_xlsx_files,
_source_group_queryset,
_spool_source_group_rows,
build_source_record_export_artifacts,
@@ -71,6 +73,32 @@ class OrganizationSourceRecordExportApiV2Test(APITestCase):
return b"".join(response.streaming_content)
return response.content
def test_xlsx_export_preserves_large_rendered_fedresurs_field_in_chunks(self):
value = "Атрибут 😀" * 6_000
with TemporaryDirectory() as directory:
spool = Path(directory) / "rows.jsonl"
spool.write_text(
json.dumps(
{"uid": "record-1", "payload.rendered_page.text": value},
ensure_ascii=False,
) + "\n",
encoding="utf-8",
)
paths = _render_xlsx_files(
row_spool_path=spool,
output_path=Path(directory) / "fedresurs.xlsx",
headers=["uid", "payload.rendered_page.text"],
records_count=1,
)
workbook = load_workbook(paths[0], read_only=True)
self.assertEqual(workbook["data"]["B2"].value, "См. overflow_values: payload.rendered_page.text")
chunks = [
row[4][4:]
for row in list(workbook["overflow_values_1"].values)[1:]
]
self.assertEqual(base64.b64decode("".join(chunks)).decode("utf-8"), value)
workbook.close()
def test_export_returns_service_unavailable_before_first_nightly_generation(self):
self.client.force_authenticate(UserFactory.create_superuser())
@@ -93,9 +121,9 @@ class OrganizationSourceRecordExportApiV2Test(APITestCase):
call_command("build_source_record_exports", stdout=command_output)
generation = load_current_source_record_export_generation()
self.assertEqual(generation.artifacts_count, 43)
self.assertEqual(generation.artifacts_count, 49)
self.assertEqual(generation.export_year, timezone.localdate().year)
self.assertIn('"artifacts_count": 43', command_output.getvalue())
self.assertIn('"artifacts_count": 49', command_output.getvalue())
def test_sanctions_xlsx_export_uses_source_contract_columns_and_boolean_flags(self):
organization = Organization.objects.create(
@@ -466,7 +494,7 @@ class OrganizationSourceRecordExportApiV2Test(APITestCase):
self.assertEqual(
response["X-Source-Export-Generated-At"], generation.generated_at
)
self.assertEqual(generation.artifacts_count, 43)
self.assertEqual(generation.artifacts_count, 49)
self.assertIn(
'filename="planned-inspections__financial-indicators_',
response["Content-Disposition"],
@@ -661,8 +689,8 @@ class OrganizationSourceRecordExportApiV2Test(APITestCase):
key=lambda item: item.file_name,
)
self.assertEqual(generation.artifacts_count, 43)
self.assertEqual(generation.files_count, 44)
self.assertEqual(generation.artifacts_count, 49)
self.assertEqual(generation.files_count, 50)
self.assertEqual(
[item.file_name for item in artifacts],
[
@@ -860,7 +888,7 @@ class OrganizationSourceRecordExportApiV2Test(APITestCase):
first_generation = build_source_record_export_artifacts()
current_generation = load_current_source_record_export_generation()
self.assertEqual(first_generation.artifacts_count, 43)
self.assertEqual(first_generation.artifacts_count, 49)
self.assertEqual(
current_generation.generation_id, first_generation.generation_id
)

View File

@@ -147,7 +147,7 @@ class SourceRecordExportArtifactsTaskTest(TestCase):
result = refresh_source_record_export_artifacts()
self.assertEqual(result["status"], "success")
self.assertEqual(result["artifacts_count"], 43)
self.assertEqual(result["artifacts_count"], 49)
self.assertEqual(result["export_year"], timezone.localdate().year)
self.assertIsNone(cache.get(settings.SOURCE_RECORD_EXPORT_LOCK_KEY))

View File

@@ -66,11 +66,20 @@ class TestCompaniesCommandsTest(TestCase):
10,
)
expected_groups = {choice.value for choice in SourceGroup}
expected_groups = {
choice.value
for choice in SourceGroup
if choice is not SourceGroup.INTEGRATED_STRUCTURE_DOCUMENTS
}
expected_sources = {
choice.value
for choice in ParserLoadLog.Source
if choice is not ParserLoadLog.Source.ROPK_SANCTIONS
if choice
not in {
ParserLoadLog.Source.ROPK_SANCTIONS,
ParserLoadLog.Source.INTEGRATED_STRUCTURE_DOCUMENTS,
ParserLoadLog.Source.FEDRESURS_COMPANY_PROFILE,
}
}
for company in companies:
self.assertEqual(
@@ -264,7 +273,7 @@ class TestCompaniesCommandsTest(TestCase):
)
self.assertEqual(
OrganizationSourceRecord.objects.count(),
20 * (len(ParserLoadLog.Source) - 1),
20 * (len(ParserLoadLog.Source) - 3),
)
def test_create_replaces_stale_source_record_for_same_legacy_row(self):