add tests

This commit is contained in:
qananasikq
2026-04-21 23:50:31 +03:00
parent f225aec4d2
commit ac2753146e
7 changed files with 742 additions and 0 deletions

24
tests/test_utils.py Normal file
View File

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