From: rohitagarwalla Date: Thu, 8 Sep 2011 06:26:21 +0000 (-0700) Subject: changing key names to confirm to api specs X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c5e05120e20e1451416f41350e312bb850451813;p=openstack-build%2Fneutron-build.git changing key names to confirm to api specs --- diff --git a/tests/unit/database_stubs.py b/tests/unit/database_stubs.py index 5b9a9c81e..20712e2a3 100644 --- a/tests/unit/database_stubs.py +++ b/tests/unit/database_stubs.py @@ -37,9 +37,9 @@ class QuantumDB(object): for net in db.network_list(tenant_id): LOG.debug("Getting network: %s", net.uuid) net_dict = {} - net_dict["tenant-id"] = net.tenant_id - net_dict["net-id"] = str(net.uuid) - net_dict["net-name"] = net.name + net_dict["tenant_id"] = net.tenant_id + net_dict["id"] = str(net.uuid) + net_dict["name"] = net.name nets.append(net_dict) except Exception, exc: LOG.error("Failed to get all networks: %s", str(exc)) @@ -52,9 +52,9 @@ class QuantumDB(object): for net in db.network_get(network_id): LOG.debug("Getting network: %s", net.uuid) net_dict = {} - net_dict["tenant-id"] = net.tenant_id - net_dict["net-id"] = str(net.uuid) - net_dict["net-name"] = net.name + net_dict["tenant_id"] = net.tenant_id + net_dict["id"] = str(net.uuid) + net_dict["name"] = net.name net.append(net_dict) except Exception, exc: LOG.error("Failed to get network: %s", str(exc)) @@ -66,9 +66,9 @@ class QuantumDB(object): try: res = db.network_create(tenant_id, net_name) LOG.debug("Created network: %s", res.uuid) - net_dict["tenant-id"] = res.tenant_id - net_dict["net-id"] = str(res.uuid) - net_dict["net-name"] = res.name + net_dict["tenant_id"] = res.tenant_id + net_dict["id"] = str(res.uuid) + net_dict["name"] = res.name return net_dict except Exception, exc: LOG.error("Failed to create network: %s", str(exc)) @@ -79,7 +79,7 @@ class QuantumDB(object): net = db.network_destroy(net_id) LOG.debug("Deleted network: %s", net.uuid) net_dict = {} - net_dict["net-id"] = str(net.uuid) + net_dict["id"] = str(net.uuid) return net_dict except Exception, exc: LOG.error("Failed to delete network: %s", str(exc)) @@ -90,8 +90,8 @@ class QuantumDB(object): net = db.network_rename(net_id, tenant_id, new_name) LOG.debug("Renamed network: %s", net.uuid) net_dict = {} - net_dict["net-id"] = str(net.uuid) - net_dict["net-name"] = net.name + net_dict["id"] = str(net.uuid) + net_dict["name"] = net.name return net_dict except Exception, exc: LOG.error("Failed to rename network: %s", str(exc)) @@ -103,9 +103,9 @@ class QuantumDB(object): for port in db.port_list(net_id): LOG.debug("Getting port: %s", port.uuid) port_dict = {} - port_dict["port-id"] = str(port.uuid) + port_dict["id"] = str(port.uuid) port_dict["net-id"] = str(port.network_id) - port_dict["int-id"] = port.interface_id + port_dict["attachment"] = port.interface_id port_dict["state"] = port.state ports.append(port_dict) return ports @@ -119,9 +119,9 @@ class QuantumDB(object): try: LOG.debug("Getting port: %s", port.uuid) port_dict = {} - port_dict["port-id"] = str(port.uuid) + port_dict["id"] = str(port.uuid) port_dict["net-id"] = str(port.network_id) - port_dict["int-id"] = port.interface_id + port_dict["attachment"] = port.interface_id port_dict["state"] = port.state port_list.append(port_dict) return port_list @@ -134,9 +134,9 @@ class QuantumDB(object): try: port = db.port_create(net_id) LOG.debug("Creating port %s", port.uuid) - port_dict["port-id"] = str(port.uuid) + port_dict["id"] = str(port.uuid) port_dict["net-id"] = str(port.network_id) - port_dict["int-id"] = port.interface_id + port_dict["attachment"] = port.interface_id port_dict["state"] = port.state return port_dict except Exception, exc: @@ -148,7 +148,7 @@ class QuantumDB(object): port = db.port_destroy(port_id, net_id) LOG.debug("Deleted port %s", port.uuid) port_dict = {} - port_dict["port-id"] = str(port.uuid) + port_dict["id"] = str(port.uuid) return port_dict except Exception, exc: LOG.error("Failed to delete port: %s", str(exc)) @@ -159,9 +159,9 @@ class QuantumDB(object): port = db.port_set_state(net_id, port_id, port_state) LOG.debug("Updated port %s", port.uuid) port_dict = {} - port_dict["port-id"] = str(port.uuid) + port_dict["id"] = str(port.uuid) port_dict["net-id"] = str(port.network_id) - port_dict["int-id"] = port.interface_id + port_dict["attachment"] = port.interface_id port_dict["state"] = port.state return port_dict except Exception, exc: @@ -173,9 +173,9 @@ class QuantumDB(object): port = db.port_set_attachment(port_id, net_id, int_id) LOG.debug("Attached interface to port %s", port.uuid) port_dict = {} - port_dict["port-id"] = str(port.uuid) + port_dict["id"] = str(port.uuid) port_dict["net-id"] = str(port.network_id) - port_dict["int-id"] = port.interface_id + port_dict["attachment"] = port.interface_id port_dict["state"] = port.state return port_dict except Exception, exc: diff --git a/tests/unit/test_database.py b/tests/unit/test_database.py index 8d7840f39..3e56b652e 100644 --- a/tests/unit/test_database.py +++ b/tests/unit/test_database.py @@ -46,26 +46,26 @@ class QuantumDBTest(unittest.TestCase): def testa_create_network(self): """test to create network""" net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1") - self.assertTrue(net1["net-name"] == "plugin_test1") + self.assertTrue(net1["name"] == "plugin_test1") def testb_get_networks(self): """test to get all networks""" net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1") - self.assertTrue(net1["net-name"] == "plugin_test1") + self.assertTrue(net1["name"] == "plugin_test1") net2 = self.dbtest.create_network(self.tenant_id, "plugin_test2") - self.assertTrue(net2["net-name"] == "plugin_test2") + self.assertTrue(net2["name"] == "plugin_test2") nets = self.dbtest.get_all_networks(self.tenant_id) count = 0 for net in nets: - if "plugin_test" in net["net-name"]: + if "plugin_test" in net["name"]: count += 1 self.assertTrue(count == 2) def testc_delete_network(self): """test to delete network""" net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1") - self.assertTrue(net1["net-name"] == "plugin_test1") - self.dbtest.delete_network(net1["net-id"]) + self.assertTrue(net1["name"] == "plugin_test1") + self.dbtest.delete_network(net1["id"]) nets = self.dbtest.get_all_networks(self.tenant_id) count = len(nets) self.assertTrue(count == 0) @@ -73,45 +73,45 @@ class QuantumDBTest(unittest.TestCase): def testd_rename_network(self): """test to rename network""" net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1") - self.assertTrue(net1["net-name"] == "plugin_test1") - net = self.dbtest.rename_network(self.tenant_id, net1["net-id"], + self.assertTrue(net1["name"] == "plugin_test1") + net = self.dbtest.rename_network(self.tenant_id, net1["id"], "plugin_test1_renamed") - self.assertTrue(net["net-name"] == "plugin_test1_renamed") + self.assertTrue(net["name"] == "plugin_test1_renamed") def teste_create_port(self): """test to create port""" net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1") - port = self.dbtest.create_port(net1["net-id"]) - self.assertTrue(port["net-id"] == net1["net-id"]) + port = self.dbtest.create_port(net1["id"]) + self.assertTrue(port["net-id"] == net1["id"]) def testf_get_ports(self): """test to get ports""" net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1") - port = self.dbtest.create_port(net1["net-id"]) - self.assertTrue(port["net-id"] == net1["net-id"]) - ports = self.dbtest.get_all_ports(net1["net-id"]) + port = self.dbtest.create_port(net1["id"]) + self.assertTrue(port["net-id"] == net1["id"]) + ports = self.dbtest.get_all_ports(net1["id"]) count = len(ports) self.assertTrue(count == 1) def testf_delete_port(self): """test to delete port""" net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1") - port = self.dbtest.create_port(net1["net-id"]) - self.assertTrue(port["net-id"] == net1["net-id"]) - ports = self.dbtest.get_all_ports(net1["net-id"]) + port = self.dbtest.create_port(net1["id"]) + self.assertTrue(port["net-id"] == net1["id"]) + ports = self.dbtest.get_all_ports(net1["id"]) for por in ports: - self.dbtest.delete_port(net1["net-id"], por["port-id"]) - ports = self.dbtest.get_all_ports(net1["net-id"]) + self.dbtest.delete_port(net1["id"], por["id"]) + ports = self.dbtest.get_all_ports(net1["id"]) count = len(ports) self.assertTrue(count == 0) def testg_plug_unplug_interface(self): """test to plug/unplug interface""" net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1") - port1 = self.dbtest.create_port(net1["net-id"]) - self.dbtest.plug_interface(net1["net-id"], port1["port-id"], "vif1.1") - port = self.dbtest.get_port(net1["net-id"], port1["port-id"]) - self.assertTrue(port[0]["int-id"] == "vif1.1") - self.dbtest.unplug_interface(net1["net-id"], port1["port-id"]) - port = self.dbtest.get_port(net1["net-id"], port1["port-id"]) - self.assertTrue(port[0]["int-id"] == None) + port1 = self.dbtest.create_port(net1["id"]) + self.dbtest.plug_interface(net1["id"], port1["id"], "vif1.1") + port = self.dbtest.get_port(net1["id"], port1["id"]) + self.assertTrue(port[0]["attachment"] == "vif1.1") + self.dbtest.unplug_interface(net1["id"], port1["id"]) + port = self.dbtest.get_port(net1["id"], port1["id"]) + self.assertTrue(port[0]["attachment"] == None)