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.TemplateElement('keypairs') elem = xmlutil.make_flat_dict('keypair', selector='keypairs', subselector='keypair') root.append(elem) return xmlutil.MasterTemplate(root, 1)
def make_volume(elem): elem.set('id') elem.set('status') elem.set('size') elem.set('availabilityZone') elem.set('createdAt') elem.set('displayName') elem.set('displayDescription') elem.set('volumeType') elem.set('snapshotId') attachments = xmlutil.SubTemplateElement(elem, 'attachments') attachment = xmlutil.SubTemplateElement(attachments, 'attachment', selector='attachments') make_attachment(attachment) metadata = xmlutil.make_flat_dict('metadata') elem.append(metadata)
def make_voltype(elem): elem.set('id') elem.set('name') extra_specs = xmlutil.make_flat_dict('extra_specs', selector='extra_specs') elem.append(extra_specs)
def construct(self): root = xmlutil.make_flat_dict('extra_specs', selector='extra_specs') return xmlutil.MasterTemplate(root, 1)
def construct(self): return xmlutil.MasterTemplate(xmlutil.make_flat_dict('keypair'), 1)
def construct(self): root = xmlutil.TemplateElement("keypairs") elem = xmlutil.make_flat_dict("keypair", selector="keypairs", subselector="keypair") root.append(elem) return xmlutil.MasterTemplate(root, 1)
def construct(self): return xmlutil.MasterTemplate(xmlutil.make_flat_dict("keypair"), 1)
def construct(self): return xmlutil.MasterTemplate(xmlutil.make_flat_dict('cloudpipe'), 1)
def construct(self): return xmlutil.MasterTemplate(xmlutil.make_flat_dict('extra_specs'), 1)
def construct(self): root = xmlutil.TemplateElement('cloudpipes') elem = xmlutil.make_flat_dict('cloudpipe', selector='cloudpipes', subselector='cloudpipe') root.append(elem) return xmlutil.MasterTemplate(root, 1)