예제 #1
0
 def test_ref_pointer_returns_default_if_no_match(
     uri: URI, document: Dict[str, Any]
 ):
     default = "default"
     assert RefPointer(uri.get("nonexistent")).resolve(
         document, default=default
     )
예제 #2
0
 def test_to_last(
     uri: URI,
     document: Dict[str, Any],
     path: Iterable[str],
     expected: Tuple[Any, Union[str, int]],
 ):
     pointer = RefPointer(uri.get("definitions", *path))
     assert pointer.to_last(document) == expected
예제 #3
0
 def test_ref_pointer_resolve(
     uri: URI,
     document: Dict[str, Any],
     method: str,
     path: Iterable[str],
     expected: Any,
 ):
     pointer = RefPointer(uri.get("definitions", *path))
     assert getattr(pointer, method)(document) == expected
예제 #4
0
 def test_ref_pointer_returns_non_dict_values(uri: URI,
                                              document: Dict[str, Any]):
     uri = uri.get("definitions").get("foo").get("type")
     assert RefPointer(uri).resolve(document) == "string"
예제 #5
0
 def test_ref_pointer_raises_on_no_match(uri: URI, document: Dict[str,
                                                                  Any]):
     with pytest.raises(JsonPointerException):
         _ = RefPointer(uri.get("nonexistent")).resolve(document)
예제 #6
0
 def test_set_fails(uri: URI, document: Dict[str, Any],
                    path: Iterable[str]):
     pointer = RefPointer(uri.get("definitions", *path))
     with pytest.raises(NotImplementedError):
         pointer.set(document, "foo")
예제 #7
0
 def test_re_pointer_path(uri: URI, path: Iterable[str], expected: str):
     pointer = RefPointer(uri.get("definitions", *path))
     assert pointer.path == expected