IAAI scraper: Playwright + SQLAlchemy, парсинг авто с аукциона, Docker-ready

This commit is contained in:
qananasikq
2026-04-07 23:45:50 +03:00
commit eddcec8141
37 changed files with 2524 additions and 0 deletions

31
tests/test_utils.py Normal file
View File

@@ -0,0 +1,31 @@
from __future__ import annotations
import unittest
from iaai_scraper.core.utils import deep_find_key
class TestDeepFindKey(unittest.TestCase):
def test_finds_key_in_nested_structure(self) -> None:
payload = {
"root": {
"target": "a",
"nested": [{"target": "b"}, {"x": 1}],
}
}
found = deep_find_key(payload, {"target"})
self.assertEqual(found, ["a", "b"])
def test_respects_max_depth(self) -> None:
payload = {"l1": {"l2": {"l3": {"target": "value"}}}}
found_too_shallow = deep_find_key(payload, {"target"}, max_depth=2)
found_enough_depth = deep_find_key(payload, {"target"}, max_depth=8)
self.assertEqual(found_too_shallow, [])
self.assertEqual(found_enough_depth, ["value"])
if __name__ == "__main__":
unittest.main()