def test_network_delete(self, mock_network_delete, mock_policy, mock_network_list): mock_policy.return_value = True test_object = utils.create_test_network(context=self.context) mock_network_list.return_value = [test_object] response = self.delete('/v1/networks/%s' % test_object.get('uuid')) self.assertEqual(204, response.status_int) self.assertTrue(mock_network_delete.called)
def test_network_create(self, mock_network_create, mock_policy): mock_policy.return_value = True test_object = utils.create_test_network(context=self.context) mock_network_create.return_value = test_object params = ('{"name": "network-test", "neutron_net_id": "test-id"}') response = self.post('/v1/networks/', params=params, content_type='application/json') self.assertEqual(200, response.status_int) self.assertTrue(mock_network_create.called)
def test_list_networks(self): uuids = [] for i in range(1, 6): network = utils.create_test_network( uuid=uuidutils.generate_uuid(), context=self.context, neutron_net_id=uuidutils.generate_uuid(), name='network' + str(i)) uuids.append(str(network['uuid'])) res = dbapi.list_networks(self.context) res_uuids = [r.uuid for r in res] self.assertEqual(sorted(uuids), sorted(res_uuids))
def test_list_networks(self): uuids = [] for i in range(1, 6): network = utils.create_test_network( uuid=uuidutils.generate_uuid(), context=self.context, neutron_net_id=uuidutils.generate_uuid(), name='network' + str(i)) uuids.append(six.text_type(network['uuid'])) res = dbapi.list_networks(self.context) res_uuids = [r.uuid for r in res] self.assertEqual(sorted(uuids), sorted(res_uuids))
def test_create_network_already_exists(self): utils.create_test_network(context=self.context, uuid='123', neutron_net_id='456') with self.assertRaisesRegex(exception.NetworkAlreadyExists, 'A network with UUID 123.*'): utils.create_test_network(context=self.context, uuid='123') with self.assertRaisesRegex(exception.NetworkAlreadyExists, 'A network with neutron_net_id 456.*'): utils.create_test_network(context=self.context, neutron_net_id='456')
def test_create_network_already_exists(self): utils.create_test_network(context=self.context, uuid='123', neutron_net_id='456') with self.assertRaisesRegex(exception.NetworkAlreadyExists, 'A network with UUID 123.*'): utils.create_test_network(context=self.context, uuid='123') with self.assertRaisesRegex(exception.NetworkAlreadyExists, 'A network with neutron_net_id 456.*'): utils.create_test_network(context=self.context, neutron_net_id='456')
def test_create_network(self): utils.create_test_network(context=self.context)
def test_create_network(self): utils.create_test_network(context=self.context)