示例#1
0
 def test_access_ips_with_empty(self):
     server = {
         "servers": [{
             'id': 'fake1',
             access_ips.AccessIPs.v4_key: '',
             access_ips.AccessIPs.v6_key: ''
         }, {
             'id': 'fake2',
             access_ips.AccessIPs.v4_key: '',
             access_ips.AccessIPs.v6_key: ''
         }]
     }
     serializer = servers.ServersTemplate()
     serializer.attach(access_ips.AccessIPsTemplate())
     output = serializer.serialize(server)
     root = etree.XML(output)
     server_nodes = root.getchildren()
     access_ipv4_node = server_nodes[0].get(
         AccessIPsXmlSerializeTest.v4_xml_key)
     access_ipv6_node = server_nodes[0].get(
         AccessIPsXmlSerializeTest.v6_xml_key)
     self.assertEqual(access_ipv4_node, '')
     self.assertEqual(access_ipv6_node, '')
     access_ipv4_node = server_nodes[1].get(
         AccessIPsXmlSerializeTest.v4_xml_key)
     access_ipv6_node = server_nodes[1].get(
         AccessIPsXmlSerializeTest.v6_xml_key)
     self.assertEqual(access_ipv4_node, '')
     self.assertEqual(access_ipv6_node, '')
示例#2
0
 def test_servers_config_drives(self):
     fake_server = {"servers": [{"id": 'fake1',
                                 config_drive.ATTRIBUTE_NAME: 'true'},
                                {"id": 'fake2',
                                 config_drive.ATTRIBUTE_NAME: 'false'}]}
     serializer = servers.ServersTemplate()
     serializer.attach(config_drive.ServersConfigDriveTemplate())
     output = serializer.serialize(fake_server)
     root = etree.XML(output)
     server_nodes = root.getchildren()
     self.assertEqual('fake1', server_nodes[0].get('id'))
     self.assertEqual('true', server_nodes[0].get(CONFIG_DRIVE_XML_KEY))
     self.assertEqual('fake2', server_nodes[1].get('id'))
     self.assertEqual('false', server_nodes[1].get(CONFIG_DRIVE_XML_KEY))