fix(parsers): unblock source status and heavy product import
All checks were successful
CI/CD Pipeline / Quality Gate (push) Successful in 19s
CI/CD Pipeline / Build and Push Images (push) Successful in 6s
CI/CD Pipeline / Internal Notify (push) Successful in 1s
CI/CD Pipeline / Deploy Dev in Dokploy (push) Successful in 1s

This commit is contained in:
2026-04-28 22:51:52 +02:00
parent e921f4b204
commit 01387ae13b
6 changed files with 182 additions and 25 deletions

View File

@@ -2,6 +2,7 @@
from __future__ import annotations
from unittest.mock import patch
from urllib.parse import urlparse
import requests
@@ -22,6 +23,7 @@ from apps.parsers.clients.minpromtorg.schemas import (
from apps.parsers.clients.proverki import ProverkiClient
from apps.parsers.clients.proverki.schemas import Inspection
from django.test import TestCase, tag
from openpyxl import load_workbook as openpyxl_load_workbook
from requests.adapters import BaseAdapter
from tests.utils import Response, TestHTTPServer
@@ -513,6 +515,40 @@ class IndustrialProductsClientTest(TestCase):
self.assertEqual(products, [])
def test_fetch_products_uses_read_only_workbook(self):
excel_bytes, rows = build_minpromtorg_products_excel(count=2)
file_name = "industrial_products_20260428.xlsx"
with TestHTTPServer() as server:
server.add_json(
"/api/kss-document-preview",
{
"data": [
{
"name": IndustrialProductsClient().query,
"files": [
{"name": file_name, "url": f"/files/{file_name}"}
],
}
]
},
)
server.add_bytes(f"/files/{file_name}", excel_bytes)
client = IndustrialProductsClient(
host=_host_from_base_url(server.base_url),
scheme="http",
http_adapter=server.adapter,
)
with patch(
"apps.parsers.clients.minpromtorg.products.load_workbook",
wraps=openpyxl_load_workbook,
) as load_workbook_mock:
products = client.fetch_products()
self.assertEqual(len(products), len(rows))
self.assertTrue(load_workbook_mock.call_args.kwargs["read_only"])
def test_get_latest_file_url_falls_back_to_excel_file(self):
client = IndustrialProductsClient()
files = [