| Total Complexity | 3 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 2 | |||
| 3 | from mandos.model.apis.pubchem_support import Filter, Flatmap |
||
| 4 | from mandos.model.apis.pubchem_support import JsonNavigator |
||
| 5 | |||
| 6 | |||
| 7 | class TestNav: |
||
| 8 | def test(self): |
||
| 9 | nav = JsonNavigator.create(dict(a=dict(b=1))) |
||
| 10 | assert (nav / "a" >> "b").contents == [1] |
||
| 11 | |||
| 12 | def test_filter(self): |
||
| 13 | nav = JsonNavigator.create([dict(a="x", b="y"), dict(a="123", b="456")]) |
||
| 14 | a = nav / Filter.key_equals("b", "y") // "a" // Flatmap.require_only() |
||
| 15 | assert a.contents == ["x"] |
||
| 16 | |||
| 17 | def test_mod(self): |
||
| 18 | nav = JsonNavigator.create([dict(a="x", b="y"), dict(a="123", b="456")]) |
||
| 19 | assert len((nav % "a").contents) == 1 |
||
| 20 | assert dict((nav % "a").contents[0]) == { |
||
| 21 | "x": dict(a="x", b="y", _landmark=""), |
||
| 22 | "123": dict(a="123", b="456", _landmark=""), |
||
| 23 | } |
||
| 24 | |||
| 25 | |||
| 26 | if __name__ == "__main__": |
||
| 27 | pytest.main() |
||
| 28 |