Esempio n. 1
0
    def test_element_attribute_items(self):
        expected = dict(a=xmlutil.Selector(1),
                        b=xmlutil.Selector(2),
                        c=xmlutil.Selector(3))
        keys = set(expected.keys())

        # Create a template element with some attributes
        elem = xmlutil.TemplateElement('test', attrib=expected)

        # Now verify items
        for k, v in elem.items():
            self.assertEqual(expected[k], v)
            keys.remove(k)

        # Did we visit all keys?
        self.assertEqual(0, len(keys))
Esempio n. 2
0
    def test_element_subselector(self):
        sel = xmlutil.Selector('a', 'b')

        # Create a template element with an explicit subselector
        elem = xmlutil.TemplateElement('test', subselector=sel)

        self.assertEqual(sel, elem.subselector)
Esempio n. 3
0
 def test_empty_selector(self):
     sel = xmlutil.Selector()
     self.assertEqual(0, len(sel.chain))
     self.assertEqual(self.obj_for_test, sel(self.obj_for_test))
Esempio n. 4
0
 def construct(self):
     sel = xmlutil.Selector('meta', xmlutil.get_items, 0)
     root = xmlutil.TemplateElement('meta', selector=sel)
     root.set('key', 0)
     root.text = 1
     return xmlutil.MasterTemplate(root, 1, nsmap=metadata_nsmap)