fix remaining parser source failures
Some checks failed
CI/CD Pipeline / Manual Action Help (push) Has been skipped
CI/CD Pipeline / Start Dev Containers in Dokploy (push) Has been skipped
CI/CD Pipeline / Drop and Recreate Dev Database (push) Has been skipped
CI/CD Pipeline / Quality Gate (push) Successful in 54s
CI/CD Pipeline / Build and Push Images (push) Failing after 2m59s
CI/CD Pipeline / Deploy Dev in Dokploy (push) Has been skipped
CI/CD Pipeline / Internal Notify (push) Successful in 1s
Some checks failed
CI/CD Pipeline / Manual Action Help (push) Has been skipped
CI/CD Pipeline / Start Dev Containers in Dokploy (push) Has been skipped
CI/CD Pipeline / Drop and Recreate Dev Database (push) Has been skipped
CI/CD Pipeline / Quality Gate (push) Successful in 54s
CI/CD Pipeline / Build and Push Images (push) Failing after 2m59s
CI/CD Pipeline / Deploy Dev in Dokploy (push) Has been skipped
CI/CD Pipeline / Internal Notify (push) Successful in 1s
This commit is contained in:
@@ -57,6 +57,7 @@ from apps.parsers.tasks import (
|
||||
)
|
||||
from django.test import TestCase, override_settings
|
||||
from openpyxl import Workbook
|
||||
from registers.models import Organization
|
||||
|
||||
from tests.apps.parsers.factories import (
|
||||
InspectionRecordFactory,
|
||||
@@ -155,6 +156,92 @@ class SyncRuProxiesTaskTestCase(TestCase):
|
||||
sync_mock.assert_called_once_with()
|
||||
|
||||
|
||||
class GenericSourceFetchTestCase(TestCase):
|
||||
"""Tests for source-specific generic fetch configuration."""
|
||||
|
||||
def test_fstec_disables_ssl_verification_for_broken_certificate_chain(self):
|
||||
class _RecordingStructuredClient:
|
||||
instances = []
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.kwargs = kwargs
|
||||
self.instances.append(self)
|
||||
|
||||
def fetch_records(self, **_kwargs):
|
||||
return []
|
||||
|
||||
with patch.object(
|
||||
parser_tasks,
|
||||
"StructuredDataClient",
|
||||
_RecordingStructuredClient,
|
||||
):
|
||||
records = parser_tasks._fetch_structured_records(
|
||||
source_key="fstec",
|
||||
file_url="https://reestr.fstec.ru/reg3",
|
||||
file_path=None,
|
||||
proxies=[],
|
||||
)
|
||||
|
||||
self.assertEqual(records, [])
|
||||
self.assertEqual(len(_RecordingStructuredClient.instances), 1)
|
||||
self.assertEqual(
|
||||
_RecordingStructuredClient.instances[0].kwargs["source"],
|
||||
"fstec",
|
||||
)
|
||||
self.assertFalse(_RecordingStructuredClient.instances[0].kwargs["verify_ssl"])
|
||||
|
||||
@override_settings(CHECKO_API_KEY="test-key", FEDRESURS_CHECKO_FALLBACK_LIMIT=10)
|
||||
def test_fedresurs_falls_back_to_checko_for_registry_organizations(self):
|
||||
organization = Organization.objects.create(
|
||||
pn_name='ООО "Тест"',
|
||||
mn_ogrn=1027700000000,
|
||||
mn_inn=7701000001,
|
||||
in_kpp=770101001,
|
||||
mn_okpo="12345678",
|
||||
)
|
||||
|
||||
class _CheckoClient:
|
||||
def __init__(self, **_kwargs):
|
||||
return
|
||||
|
||||
def get_company(self, _request):
|
||||
return SimpleNamespace(
|
||||
data=SimpleNamespace(
|
||||
ogrn=str(organization.mn_ogrn),
|
||||
inn=str(organization.mn_inn),
|
||||
short_name=organization.pn_name,
|
||||
bankruptcy=(
|
||||
SimpleNamespace(
|
||||
type="Сообщение о введении наблюдения",
|
||||
date="2026-04-01",
|
||||
case_number="А40-1/2026",
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
with (
|
||||
patch.object(
|
||||
parser_tasks,
|
||||
"_fetch_structured_records",
|
||||
side_effect=RuntimeError("HTTP 401"),
|
||||
),
|
||||
patch.object(parser_tasks, "CheckoClient", _CheckoClient),
|
||||
):
|
||||
records = parser_tasks._fetch_fedresurs_bankruptcy_records(
|
||||
file_url=None,
|
||||
file_path=None,
|
||||
proxies=[],
|
||||
)
|
||||
|
||||
self.assertEqual(len(records), 1)
|
||||
self.assertEqual(records[0].source, "fedresurs_bankruptcy")
|
||||
self.assertEqual(records[0].inn, str(organization.mn_inn))
|
||||
self.assertEqual(records[0].ogrn, str(organization.mn_ogrn))
|
||||
self.assertEqual(records[0].record_date, "2026-04-01")
|
||||
self.assertEqual(records[0].payload["provider"], "checko")
|
||||
|
||||
|
||||
@override_settings(
|
||||
CELERY_TASK_ALWAYS_EAGER=True,
|
||||
CELERY_TASK_EAGER_PROPAGATES=True,
|
||||
|
||||
Reference in New Issue
Block a user