def test_destroy(self, mock_vnf_destroy): vnf_resource = objects.VnfResource(context=self.context, **fakes.fake_vnf_resource_data( self.vnf_instance.id)) vnf_resource.create() vnf_resource.destroy(self.context) mock_vnf_destroy.assert_called_with(self.context, vnf_resource.id)
def test_vnf_resource_create(self): resource_data = fakes.fake_vnf_resource_data( self.vnf_instance.id) resource_data.update({'id': uuidsentinel.id}) result = vnf_resources._vnf_resource_create( self.context, resource_data) self.assertTrue(result.id) self.assertEqual('test', result.resource_name)
def test_save_error(self): vnf_resource = objects.VnfResource(context=self.context, **fakes.fake_vnf_resource_data( self.vnf_instance.id)) vnf_resource.create() vnf_resource.destroy(self.context) vnf_resource.resource_name = 'fake' self.assertRaises(exceptions.VnfResourceNotFound, vnf_resource.save)
def test_create_with_id(self): vnf_resource_data = fakes.fake_vnf_resource_data(self.vnf_instance.id) vnf_resource_data.update({'id': uuidsentinel.uuid}) vnf_resource_obj = objects.VnfResource(context=self.context, **vnf_resource_data) self.assertRaises(exceptions.ObjectActionError, vnf_resource_obj.create)
def test_get_by_vnf_instance_id(self): vnf_resource = objects.VnfResource(context=self.context, **fakes.fake_vnf_resource_data( self.vnf_instance.id)) vnf_resource.create() vnf_resource_list = objects.VnfResourceList() result = vnf_resource_list.get_by_vnf_instance_id( self.context, self.vnf_instance.id) self.assertIsInstance(result.objects, list) self.assertTrue(result.objects)
def test_save(self, mock_resource_update): vnf_resource = objects.VnfResource(context=self.context, **fakes.fake_vnf_resource_data( self.vnf_instance.id)) vnf_resource.create() mock_resource_update.return_value = \ fakes.vnf_resource_model_object(vnf_resource) vnf_resource.resource_name = 'fake' vnf_resource.save() mock_resource_update.assert_called_with(self.context, vnf_resource.id, {'resource_name': 'fake'})
def test_create(self): vnf_resource = objects.VnfResource(context=self.context, **fakes.fake_vnf_resource_data( self.vnf_instance.id)) vnf_resource.create() self.assertTrue(vnf_resource.id)
def _create_vnf_resource(self): vnf_resource = vnf_resources.VnfResource( context=self.context, **fakes.fake_vnf_resource_data(self.vnf_instance.id)) vnf_resource.create() return vnf_resource