fix(parsers): make source jobs resumable
All checks were successful
CI/CD Pipeline / Quality Gate (push) Successful in 1m11s
CI/CD Pipeline / Build and Push Images (push) Successful in 19s
CI/CD Pipeline / Internal Notify (push) Successful in 0s
CI/CD Pipeline / Deploy Dev via Compose (push) Successful in 24s

This commit is contained in:
2026-08-14 17:02:56 +02:00
parent a0eb0a5303
commit 31eaa7e907
14 changed files with 884 additions and 476 deletions

View File

@@ -6,6 +6,7 @@ from django.core.cache import cache
from django.urls import reverse
from organizations.models import (
ArbitrationExtension,
ElectronicDocumentExchangeExtension,
Organization,
OrganizationSourceRecord,
PlannedInspectionExtension,
@@ -335,6 +336,58 @@ class OrganizationSourceExtensionsApiV2Test(APITestCase):
self.assertIsNone(ascending.data["data"][-1]["record_date"])
self.assertIsNone(descending.data["data"][-1]["record_date"])
def test_flat_gosedo_records_support_frontend_sorting_fields(self):
records = []
for external_id, name, full_name, attestation_status in (
("GOSEDO-BETA", "Организация Бета", "Полное имя Бета", "not_attested"),
("GOSEDO-ALPHA", "Организация Альфа", "Полное имя Альфа", "attested"),
):
organization = create_frontend_organization(
name=name,
full_name=full_name,
inn="7707083815" if external_id == "GOSEDO-BETA" else "7707083816",
ogrn=(
"1027700132015" if external_id == "GOSEDO-BETA" else "1027700132016"
),
)
extension = ElectronicDocumentExchangeExtension.objects.create(
organization=organization,
title="Электронный документооборот",
)
records.append(
OrganizationSourceRecord.objects.create(
extension=extension,
record_type="participant",
source="gosedo_address_directory",
external_id=external_id,
payload={"attestation_status": attestation_status},
)
)
endpoint = reverse("api_v2:organizations:organization-source-records-list")
params = {
"source_group": "electronic_document_exchange",
"source": "gosedo_address_directory",
"record_type": "participant",
}
expected_ascending = [records[1].external_id, records[0].external_id]
expected_descending = list(reversed(expected_ascending))
for ordering, expected in (
("extension__organization__full_name", expected_ascending),
("-extension__organization__full_name", expected_descending),
("payload__attestation_status", expected_ascending),
("-payload__attestation_status", expected_descending),
):
with self.subTest(ordering=ordering):
response = self.client.get(endpoint, {**params, "ordering": ordering})
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
[item["external_id"] for item in response.data["data"]],
expected,
)
def test_flat_source_records_rejects_invalid_date_range_and_ordering(self):
response = self.client.get(
reverse("api_v2:organizations:organization-source-records-list"),