fix: align media upload and gosedo records
All checks were successful
CI/CD Pipeline / Quality Gate (push) Successful in 1m13s
CI/CD Pipeline / Build and Push Images (push) Successful in 20s
CI/CD Pipeline / Internal Notify (push) Successful in 1s
CI/CD Pipeline / Deploy Dev via Compose (push) Successful in 30s

This commit is contained in:
2026-08-20 11:43:00 +02:00
parent d95a002d84
commit f2e36a8991
5 changed files with 207 additions and 15 deletions

View File

@@ -389,6 +389,113 @@ class OrganizationSourceExtensionsApiV2Test(APITestCase):
expected,
)
def test_flat_gosedo_records_include_all_linked_types_and_record_sorting(self):
organization = create_frontend_organization(
name="Связанная организация",
inn="7707083828",
ogrn="1027700132028",
)
extension = ElectronicDocumentExchangeExtension.objects.create(
organization=organization,
title="Электронный документооборот",
)
for (
record_type,
external_id,
title,
full_name,
medo_address,
registration_number,
) in (
(
"participant",
"GOSEDO-PARTICIPANT",
"Участник",
"Полное имя участника",
"MEDO-3",
"3",
),
(
"operator",
"GOSEDO-OPERATOR",
"Оператор",
"Полное имя оператора",
"MEDO-1",
"1",
),
(
"organizer",
"GOSEDO-ORGANIZER",
"Организатор",
"Полное имя организатора",
"MEDO-2",
"2",
),
):
OrganizationSourceRecord.objects.create(
extension=extension,
record_type=record_type,
source="gosedo_address_directory",
external_id=external_id,
title=title,
payload={
"full_name": full_name,
"medo_address": medo_address,
"registration_number": registration_number,
},
)
endpoint = reverse("api_v2:organizations:organization-source-records-list")
params = {
"source_group": "electronic_document_exchange",
"source": "gosedo_address_directory",
"organization": str(organization.uid),
}
response = self.client.get(endpoint, params)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
{item["record_type"] for item in response.data["data"]},
{"participant", "operator", "organizer"},
)
expected_by_ordering = {
"record_type": [
"GOSEDO-OPERATOR",
"GOSEDO-ORGANIZER",
"GOSEDO-PARTICIPANT",
],
"external_id": [
"GOSEDO-OPERATOR",
"GOSEDO-ORGANIZER",
"GOSEDO-PARTICIPANT",
],
"payload__full_name": [
"GOSEDO-OPERATOR",
"GOSEDO-ORGANIZER",
"GOSEDO-PARTICIPANT",
],
"payload__medo_address": [
"GOSEDO-OPERATOR",
"GOSEDO-ORGANIZER",
"GOSEDO-PARTICIPANT",
],
"payload__registration_number": [
"GOSEDO-OPERATOR",
"GOSEDO-ORGANIZER",
"GOSEDO-PARTICIPANT",
],
}
for ordering, expected in expected_by_ordering.items():
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_media_records_support_frontend_sorting_fields(self):
organization = create_frontend_organization(
name="Media sorting organization",