feat: add gosedo and media news sources
All checks were successful
All checks were successful
This commit is contained in:
@@ -22,7 +22,12 @@ from apps.parsers.models import (
|
||||
)
|
||||
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
|
||||
from django.test import TestCase, override_settings
|
||||
from organizations.models import Organization
|
||||
from organizations.models import (
|
||||
ElectronicDocumentExchangeExtension,
|
||||
MediaMentionExtension,
|
||||
Organization,
|
||||
OrganizationSourceRecord,
|
||||
)
|
||||
from organizations.test_companies import TestCompanyDatasetService
|
||||
|
||||
from tests.apps.parsers.factories import (
|
||||
@@ -319,6 +324,54 @@ class StateCorpExchangeServiceTest(TestCase):
|
||||
url="https://trudvsem.ru/vacancy/001",
|
||||
payload={"vacancy_source": "trudvsem"},
|
||||
)
|
||||
gosedo_extension = ElectronicDocumentExchangeExtension.objects.create(
|
||||
organization=organization,
|
||||
title="Электронный документооборот",
|
||||
)
|
||||
OrganizationSourceRecord.objects.create(
|
||||
extension=gosedo_extension,
|
||||
record_type="participant",
|
||||
source=ParserLoadLog.Source.GOSEDO_ADDRESS_DIRECTORY,
|
||||
external_id="gosedo-participant-001",
|
||||
title=organization.name,
|
||||
record_date="2026-08-10",
|
||||
status="active",
|
||||
url="https://gosedo.ru/wp-content/uploads/files/addresseesActual.html",
|
||||
load_batch=10,
|
||||
payload={
|
||||
"source_version": "633",
|
||||
"source_published_at": "2026-08-10",
|
||||
"short_name": organization.short_name,
|
||||
"full_name": organization.full_name,
|
||||
"attestation_status": "attested",
|
||||
"registration_type": "ogrn",
|
||||
"registration_number": organization.ogrn,
|
||||
"operator_uid": "operator-001",
|
||||
},
|
||||
)
|
||||
media_extension = MediaMentionExtension.objects.create(
|
||||
organization=organization,
|
||||
title="Упоминания в СМИ",
|
||||
)
|
||||
OrganizationSourceRecord.objects.create(
|
||||
extension=media_extension,
|
||||
record_type="media_mention",
|
||||
source=ParserLoadLog.Source.MEDIA_NEWS,
|
||||
external_id="a" * 64,
|
||||
title="Новый производственный комплекс",
|
||||
record_date="2026-07-15",
|
||||
status="positive",
|
||||
url="https://example.test/news/1",
|
||||
load_batch=11,
|
||||
payload={
|
||||
"news_source": "Тестовое СМИ",
|
||||
"published_at": "2026-07-15",
|
||||
"sentiment": "positive",
|
||||
"excerpt_lines": ["Источник", "Заголовок", "Лид", "Деталь"],
|
||||
"full_text": "Источник\nЗаголовок\nЛид\nДеталь\nПолный текст",
|
||||
"okpo": organization.okpo,
|
||||
},
|
||||
)
|
||||
|
||||
package = StateCorpExchangeService.build_package(actual_date="2026-03-15")
|
||||
self.assertEqual(package.payload_counts["organizations"], 1)
|
||||
@@ -334,6 +387,8 @@ class StateCorpExchangeServiceTest(TestCase):
|
||||
self.assertEqual(package.payload_counts["defense_unreliable_suppliers"], 1)
|
||||
self.assertEqual(package.payload_counts["information_security_registries"], 1)
|
||||
self.assertEqual(package.payload_counts["labor_vacancies"], 1)
|
||||
self.assertEqual(package.payload_counts["electronic_document_exchange"], 1)
|
||||
self.assertEqual(package.payload_counts["media_mentions"], 1)
|
||||
|
||||
payload = _decode_package_payload(package)
|
||||
self.assertNotIn(
|
||||
@@ -342,8 +397,23 @@ class StateCorpExchangeServiceTest(TestCase):
|
||||
)
|
||||
|
||||
self.assertEqual(payload["format"], StateCorpExchangeService.PAYLOAD_FORMAT)
|
||||
self.assertEqual(payload["schema_version"], 3)
|
||||
self.assertEqual(payload["manifest"]["schema_version"], 3)
|
||||
self.assertEqual(payload["schema_version"], 4)
|
||||
self.assertEqual(payload["manifest"]["schema_version"], 4)
|
||||
self.assertEqual(payload["manifest"]["sections"], list(payload["data"]))
|
||||
self.assertIn("electronic_document_exchange", payload["data"])
|
||||
self.assertIn("media_mentions", payload["data"])
|
||||
self.assertEqual(
|
||||
payload["data"]["electronic_document_exchange"][0]["source_version"],
|
||||
"633",
|
||||
)
|
||||
self.assertEqual(
|
||||
payload["data"]["media_mentions"][0]["excerpt_lines"],
|
||||
["Источник", "Заголовок", "Лид", "Деталь"],
|
||||
)
|
||||
self.assertEqual(
|
||||
payload["data"]["media_mentions"][0]["full_text"],
|
||||
"Источник\nЗаголовок\nЛид\nДеталь\nПолный текст",
|
||||
)
|
||||
self.assertEqual(payload["manifest"]["source_system"], "mostovik")
|
||||
self.assertNotIn("registry_memberships", payload["data"])
|
||||
self.assertNotIn("registry_memberships", payload["manifest"]["sections"])
|
||||
|
||||
Reference in New Issue
Block a user