def test_vars(self): # test dereferencing vars resource = self._getTestResource() query = { "eval": "$aDict", "vars": {"aDict": {"aRef": {"eval": "::test"}, "aTemplate": "{{ true }}"}}, } result = Ref(query).resolve_one(RefContext(resource)) self.assertEqual(result, {"aRef": resource, "aTemplate": True}) query = {"eval": "$aRef", "vars": {"aRef": {"eval": "::test"}}} assert Ref.is_ref(query["vars"]["aRef"]) result = Ref(query).resolve_one(RefContext(resource)) self.assertEqual(result, resource)
def test_refs(self): assert Ref.is_ref({"ref": "::name"}) assert not Ref.is_ref({"ref": "::name", "somethingUnexpected": 1}) assert Ref.is_ref({"ref": "::name", "vars": {"a": None}})