feat: import gosedo and media news sources
All checks were successful
All checks were successful
This commit is contained in:
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
from datetime import date
|
||||
|
||||
from apps.external_data.models import ElectronicDocumentExchangeEntry, MediaMention
|
||||
from django.test import override_settings
|
||||
from rest_framework import status
|
||||
from rest_framework.test import APITestCase
|
||||
@@ -212,3 +213,47 @@ class ExternalDataApiTest(APITestCase):
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data["count"], 1)
|
||||
self.assertEqual(response.data["results"][0]["lines"][0]["line_code"], "1600")
|
||||
|
||||
def test_gosedo_and_media_endpoints_filter_and_separate_full_text(self):
|
||||
ElectronicDocumentExchangeEntry.objects.create(
|
||||
organization=self.organization,
|
||||
external_id="gosedo-1",
|
||||
record_type="participant",
|
||||
title="АО Тест",
|
||||
status="active",
|
||||
attestation_status="attested",
|
||||
source_version="633",
|
||||
source_published_at=date(2026, 8, 10),
|
||||
)
|
||||
mention = MediaMention.objects.create(
|
||||
organization=self.organization,
|
||||
external_id="a" * 64,
|
||||
news_source="Тестовое СМИ",
|
||||
title="Заголовок",
|
||||
sentiment="positive",
|
||||
published_at=date(2026, 7, 1),
|
||||
excerpt_lines=["1", "2", "3", "4"],
|
||||
full_text="1\n2\n3\n4\n5",
|
||||
)
|
||||
|
||||
gosedo_response = self.client.get(
|
||||
f"/api/v1/electronic-document-exchange/?organization={self.organization.id}"
|
||||
"&record_type=participant&attestation_status=attested&source_version=633"
|
||||
"&source_published_at_from=2026-08-01&source_published_at_to=2026-08-31"
|
||||
)
|
||||
media_list_response = self.client.get(
|
||||
f"/api/v1/media-mentions/?organization={self.organization.id}"
|
||||
"&source=Тестовое СМИ&sentiment=positive"
|
||||
)
|
||||
media_detail_response = self.client.get(f"/api/v1/media-mentions/{mention.id}/")
|
||||
|
||||
self.assertEqual(gosedo_response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(gosedo_response.data["count"], 1)
|
||||
self.assertEqual(media_list_response.status_code, status.HTTP_200_OK)
|
||||
self.assertNotIn("full_text", media_list_response.data["results"][0])
|
||||
self.assertEqual(
|
||||
media_list_response.data["results"][0]["excerpt_lines"],
|
||||
["1", "2", "3", "4"],
|
||||
)
|
||||
self.assertEqual(media_detail_response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(media_detail_response.data["full_text"], "1\n2\n3\n4\n5")
|
||||
|
||||
Reference in New Issue
Block a user