Ejemplo n.º 1
0
    def test_element_for_exclude_returns_none(self):
        settings = {"baz": "jack"}
        p = Base.ParamPath(
            "baz",
            path="foo/bar",
            vartype=None,
            condition=None,
            values=None,
            exclude=True,
        )

        result = p.element(self.elm, settings, False)

        self.assertIsNone(result)
Ejemplo n.º 2
0
    def test_element_for_vartype_member_for_string(self):
        p = Base.ParamPath("baz",
                           path="foo/bar/baz",
                           vartype="member",
                           condition=None,
                           values=None)
        settings = {"baz": "jack"}

        result = p.element(self.elm, settings, False)
        self.assertIsNotNone(result)

        elm = result.findall("./foo/bar/baz/member")
        self.assertTrue(elm)
        self.assertEqual(1, len(elm))
        self.assertEqual(settings["baz"], elm[0].text)
Ejemplo n.º 3
0
    def test_element_for_vartype_member_for_list(self):
        p = Base.ParamPath("baz",
                           path="foo/bar/baz",
                           vartype="member",
                           condition=None,
                           values=None)
        settings = {"baz": ["jack", "john", "jane", "margret"]}

        result = p.element(self.elm, settings, False)
        self.assertIsNotNone(result)

        elms = result.findall("./foo/bar/baz/member")
        self.assertEqual(len(settings["baz"]), len(elms))

        for elm in elms:
            self.assertTrue(elm.text in settings["baz"])
Ejemplo n.º 4
0
    def test_element_path_has_variable(self):
        p = Base.ParamPath("baz",
                           path="{mode}/bar/baz",
                           vartype=None,
                           condition=None,
                           values=None)
        settings = {"baz": "jack", "mode": "layer3"}

        result = p.element(self.elm, settings, False)
        self.assertIsNotNone(result)

        elm = result.find("./layer3/bar/baz")
        self.assertIsNotNone(elm,
                             msg="Failed: elm = {0}".format(
                                 ET.tostring(result)))
        self.assertEqual(settings["baz"], elm.text)