Coverage for tests/tests_unit/test_notifications.py: 64%
14 statements
« prev ^ index » next coverage.py v7.6.2, created at 2024-10-10 03:02 +0300
« prev ^ index » next coverage.py v7.6.2, created at 2024-10-10 03:02 +0300
1import pytest_cases
2from services.notifications.builder import _get_object_field
5class GetObjectFieldCases:
6 def case_only_dict(self):
7 return {"a": {"b": "c"}}, ["a", "b"], "c"
9 def case_one_level(self):
10 return {"a": "b"}, ["a"], "b"
12 def case_list_simple(self):
13 return {"a": [{"b": "c"}]}, ["a", 0, "b"], "c"
15 def case_list_multilevel(self):
16 return {"a": [[{"b": "c"}]]}, ["a", 0, 0, "b"], "c"
19@pytest_cases.parametrize_with_cases(
20 "object_,field_path,result", cases=GetObjectFieldCases
21)
22def test_get_object_field(object_, field_path, result):
23 assert _get_object_field(object_, field_path) == result