示例#1
0
    def test_vars(self):
        # test dereferencing vars
        resource = self._getTestResource()
        query = {
            "eval": "$aDict",
            "vars": {
                "aDict": {
                    "aRef": {
                        "eval": "::test"
                    },
                    "aTemplate": "{{ true }}"
                }
            },
        }
        result = Ref(query).resolveOne(RefContext(resource))
        self.assertEqual(result, {"aRef": resource, "aTemplate": True})

        query = {"eval": "$aRef", "vars": {"aRef": {"eval": "::test"}}}
        assert Ref.isRef(query["vars"]["aRef"])
        result = Ref(query).resolveOne(RefContext(resource))
        self.assertEqual(result, resource)
示例#2
0
 def test_refs(self):
     assert Ref.isRef({"ref": "::name"})
     assert not Ref.isRef({"ref": "::name", "somethingUnexpected": 1})
     assert Ref.isRef({"ref": "::name", "vars": {"a": None}})