def test_get_with_one_allocation(self): db_api.share_network_create(self.fake_context, self.share_nw_dict) db_api.network_allocation_create(self.fake_context, self.allocation_dict) result = db_api.share_network_get(self.fake_context, self.share_nw_dict["id"]) self.assertEqual(len(result["network_allocations"]), 1) self._check_fields(expected=self.allocation_dict, actual=result["network_allocations"][0])
def test_network_allocations_relation(self): db_api.share_network_create(self.fake_context, self.share_nw_dict) db_api.network_allocation_create(self.fake_context, self.allocation_dict) db_api.network_allocation_delete(self.fake_context, self.allocation_dict["id"]) result = db_api.share_network_get(self.fake_context, self.share_nw_dict["id"]) self.assertEqual(len(result["network_allocations"]), 0)
def test_get_with_two_allocations(self): allocation_dict2 = dict(self.allocation_dict) allocation_dict2["id"] = "fake port id2" db_api.share_network_create(self.fake_context, self.share_nw_dict) db_api.network_allocation_create(self.fake_context, self.allocation_dict) db_api.network_allocation_create(self.fake_context, allocation_dict2) result = db_api.share_network_get(self.fake_context, self.share_nw_dict["id"]) self.assertEqual(len(result["network_allocations"]), 2)