def test_server_config_drive(self): fake_server = {"server": {"id": 'fake', config_drive.ATTRIBUTE_NAME: 'true'}} serializer = servers.ServerTemplate() serializer.attach(config_drive.ServerConfigDriveTemplate()) output = serializer.serialize(fake_server) root = etree.XML(output) self.assertEqual(root.get(CONFIG_DRIVE_XML_KEY), 'true')
def test_access_ip_with_empty(self): server = { "server": { 'id': 'fake', access_ips.AccessIPs.v4_key: '', access_ips.AccessIPs.v6_key: '' } } serializer = servers.ServerTemplate() serializer.attach(access_ips.AccessIPTemplate()) output = serializer.serialize(server) root = etree.XML(output) access_ipv4_node = root.get(AccessIPsXmlSerializeTest.v4_xml_key) access_ipv6_node = root.get(AccessIPsXmlSerializeTest.v6_xml_key) self.assertEqual(access_ipv4_node, '') self.assertEqual(access_ipv6_node, '')