def test_serialize_extension(self):
    serializer = base_extensions.ExtensionTemplate()
    data = {'extension': {'name': 'ext1', 'namespace': 'http://docs.rack.com/servers/api/ext/pie/v1.0', 'alias': 'RS-PIE', 'updated': '2011-01-22T13:25:27-06:00', 'description': 'Adds the capability to share an image.', 'links': [{'rel': 'describedby', 'type': 'application/pdf', 'href': 'http://docs.rack.com/servers/api/ext/cs.pdf'}, {'rel': 'describedby', 'type': 'application/vnd.sun.wadl+xml', 'href': 'http://docs.rack.com/servers/api/ext/cs.wadl'}]}}
    xml = serializer.serialize(data)
    root = etree.XML(xml)
    ext_dict = data['extension']
    self.assertEqual(root.findtext('{0}description'.format(NS)), ext_dict['description'])
    for key in ['name', 'namespace', 'alias', 'updated']:
        self.assertEqual(root.get(key), ext_dict[key])
    link_nodes = root.findall('{0}link'.format(ATOMNS))
    self.assertEqual(len(link_nodes), 2)
    for (i, link) in enumerate(ext_dict['links']):
        for (key, value) in link.items():
            self.assertEqual(link_nodes[i].get(key), value)
    xmlutil.validate_schema(root, 'extension')
def test_serialize_extension(self):
    serializer = base_extensions.ExtensionTemplate()
    data = {'extension': {'name': 'ext1', 'namespace': 'http://docs.rack.com/servers/api/ext/pie/v1.0', 'alias': 'RS-PIE', 'updated': '2011-01-22T13:25:27-06:00', 'description': 'Adds the capability to share an image.', 'links': [{'rel': 'describedby', 'type': 'application/pdf', 'href': 'http://docs.rack.com/servers/api/ext/cs.pdf'}, {'rel': 'describedby', 'type': 'application/vnd.sun.wadl+xml', 'href': 'http://docs.rack.com/servers/api/ext/cs.wadl'}]}}
    xml = serializer.serialize(data)
    root = etree.XML(xml)
    ext_dict = data['extension']
    self.assertEqual(root.findtext('{0}description'.format(NS)), ext_dict['description'])
    for key in ['name', 'namespace', 'alias', 'updated']:
        self.assertEqual(root.get(key), ext_dict[key])
    link_nodes = root.findall('{0}link'.format(ATOMNS))
    self.assertEqual(len(link_nodes), 2)
    for (i, link) in enumerate(ext_dict['links']):
        for (key, value) in link.items():
            self.assertEqual(link_nodes[i].get(key), value)
    xmlutil.validate_schema(root, 'extension')