fix pre-commit
Some checks failed
CI/CD Pipeline / Telegram Notify Success (push) Has been cancelled
CI/CD Pipeline / Run Tests (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (pull_request) Successful in 1m42s
CI/CD Pipeline / Run Tests (pull_request) Successful in 2m25s
CI/CD Pipeline / Telegram Notify Success (pull_request) Successful in 1m34s

This commit is contained in:
2026-03-17 13:55:34 +01:00
parent 3d298ce352
commit 25176f31b4
31 changed files with 653 additions and 553 deletions

View File

@@ -69,8 +69,12 @@ class RegistryOrganizationResolverTest(TestCase):
self.assertEqual(lookup.by_ogrn, {})
def test_resolve_organization_id_by_unique_inn_and_ogrn(self):
org_by_inn = OrganizationFactory(mn_inn=7_701_001_001, mn_ogrn=10_277_001_000_001)
org_by_ogrn = OrganizationFactory(mn_inn=7_701_001_002, mn_ogrn=10_277_001_000_002)
org_by_inn = OrganizationFactory(
mn_inn=7_701_001_001, mn_ogrn=10_277_001_000_001
)
org_by_ogrn = OrganizationFactory(
mn_inn=7_701_001_002, mn_ogrn=10_277_001_000_002
)
lookup = RegistryOrganizationResolver.build_lookup(
[
(org_by_inn.mn_inn, None),
@@ -103,37 +107,39 @@ class ParserLoadLogServiceRetryTest(TestCase):
batch_id=2,
)
with patch.object(ParserLoadLogService, "get_next_batch_id", side_effect=[1, 2]):
with patch.object(
ParserLoadLogService,
"create_load_log",
side_effect=[IntegrityError("duplicate"), log],
) as create_mock:
created_log, batch_id = (
ParserLoadLogService.create_load_log_with_next_batch_id(
source=ParserLoadLog.Source.INDUSTRIAL
)
)
with patch.object(
ParserLoadLogService, "get_next_batch_id", side_effect=[1, 2]
), patch.object(
ParserLoadLogService,
"create_load_log",
side_effect=[IntegrityError("duplicate"), log],
) as create_mock:
(
created_log,
batch_id,
) = ParserLoadLogService.create_load_log_with_next_batch_id(
source=ParserLoadLog.Source.INDUSTRIAL
)
self.assertEqual(created_log, log)
self.assertEqual(batch_id, 2)
self.assertEqual(create_mock.call_count, 2)
def test_create_load_log_with_next_batch_id_raises_after_max_retries(self):
with patch.object(ParserLoadLogService, "get_next_batch_id", return_value=1):
with patch.object(
ParserLoadLogService,
"create_load_log",
side_effect=IntegrityError("duplicate"),
):
with self.assertRaisesMessage(
RuntimeError,
"Failed to allocate unique batch_id",
):
ParserLoadLogService.create_load_log_with_next_batch_id(
source=ParserLoadLog.Source.INDUSTRIAL,
max_retries=2,
)
with patch.object(
ParserLoadLogService, "get_next_batch_id", return_value=1
), patch.object(
ParserLoadLogService,
"create_load_log",
side_effect=IntegrityError("duplicate"),
), self.assertRaisesMessage(
RuntimeError,
"Failed to allocate unique batch_id",
):
ParserLoadLogService.create_load_log_with_next_batch_id(
source=ParserLoadLog.Source.INDUSTRIAL,
max_retries=2,
)
class SmallParserServiceQueryTest(TestCase):
@@ -177,7 +183,9 @@ class SmallParserServiceQueryTest(TestCase):
load_batch=12,
)
self.assertEqual(ProcurementService.find_by_customer_name("Тестовый").count(), 2)
self.assertEqual(
ProcurementService.find_by_customer_name("Тестовый").count(), 2
)
self.assertEqual(
ProcurementService.find_by_customer_name("Тестовый", batch_id=11).count(),
1,