def make_voltype(elem): elem.set('id') elem.set('name') elem.set('description') elem.set('qos_specs_id') extra_specs = xmlutil.make_flat_dict('extra_specs', selector='extra_specs') elem.append(extra_specs)
def construct(self): root = xmlutil.TemplateElement('host') elem = xmlutil.make_flat_dict('resource', selector='host', subselector='resource') root.append(elem) return xmlutil.MasterTemplate(root, 1)
def test_make_flat_dict(self): expected_xml = ("<?xml version='1.0' encoding='UTF-8'?>\n" '<wrapper><a>foo</a><b>bar</b></wrapper>') root = xmlutil.make_flat_dict('wrapper') tmpl = xmlutil.MasterTemplate(root, 1) result = tmpl.serialize(dict(wrapper=dict(a='foo', b='bar'))) self.assertEqual(result, expected_xml)
def construct(self): root = xmlutil.make_flat_dict('encryption', selector='encryption') return xmlutil.MasterTemplate(root, 1)
def construct(self): root = xmlutil.make_flat_dict('extra_specs', selector='extra_specs') return xmlutil.MasterTemplate(root, 1)
def construct(self): root = xmlutil.make_flat_dict("encryption", selector="encryption") return xmlutil.MasterTemplate(root, 1)
def construct(self): root = xmlutil.make_flat_dict("qos_specs", selector="qos_specs") return xmlutil.MasterTemplate(root, 1)
def construct(self): return xmlutil.MasterTemplate(xmlutil.make_flat_dict('specs'), 1)
def test_make_flat_dict(self): expected_xml = "<?xml version='1.0' encoding='UTF-8'?>\n" "<wrapper><a>foo</a><b>bar</b></wrapper>" root = xmlutil.make_flat_dict("wrapper") tmpl = xmlutil.MasterTemplate(root, 1) result = tmpl.serialize(dict(wrapper=dict(a="foo", b="bar"))) self.assertEqual(result, expected_xml)