def test_trigger_post_none(self, pipe_mock, assem_mock, resp_mock, request_mock): obj = trigger.TriggerController() assem_mock.return_value.trigger_workflow.side_effect = ( exception.ResourceNotFound(name='trigger', id='test_id')) pipe_mock.return_value.trigger_workflow.side_effect = ( exception.ResourceNotFound(name='trigger', id='test_id')) obj.post('test_id') self.assertEqual(404, resp_mock.status) tw = assem_mock.return_value.trigger_workflow tw.assert_called_once_with('test_id') tw = pipe_mock.return_value.trigger_workflow tw.assert_called_once_with('test_id')
def get_by_uuid(cls, context, app_id): try: session = sql.Base.get_session() return session.query(cls).filter_by(uuid=app_id).one() except sa.orm.exc.NoResultFound as e: LOG.exception(e) raise exception.ResourceNotFound(id=app_id, name='plan')
def test_app_get_notfound(self, AppHandler, resp_mock, request_mock): hand_get = AppHandler.return_value.get hand_get.side_effect = exception.ResourceNotFound(name='app', id='test_id') app.AppController('test_id').get() hand_get.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_plan_get_not_found(self, PlanHandler, resp_mock, request_mock): hand_get = PlanHandler.return_value.get hand_get.side_effect = exception.ResourceNotFound(name='plan', id='test_id') plan.PlanController('test_id').get() hand_get.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_plan_delete_not_found(self, PlanHandler, resp_mock, request_mock): hand_delete = PlanHandler.return_value.delete hand_delete.side_effect = exception.ResourceNotFound(name='plan', plan_id='test_id') obj = plan.PlanController('test_id') obj.delete() hand_delete.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_stack_get_not_found(self, StackHandler, resp_mock, request_mock): hand_get = StackHandler.return_value.get hand_get.side_effect = exception.ResourceNotFound(id='test_id', name='stack') cont = infrastructure.InfrastructureStackController('test_id') cont.get() hand_get.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_pipeline_delete_not_found(self, PipelineHandler, resp_mock, request_mock): hand_delete = PipelineHandler.return_value.delete hand_delete.side_effect = exception.ResourceNotFound( name='pipeline', pipeline_id='test_id') pipeline.PipelineController('test_id').delete() hand_delete.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_image_get_not_found(self, ImageHandler, resp_mock, request_mock): hand_get = ImageHandler.return_value.get hand_get.side_effect = exception.ResourceNotFound(name='image', image_id='test_id') cont = image.ImageController('test_id') cont.get() hand_get.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_lp_get_not_found(self, handler_mock, resp_mock, request_mock): handler_get = handler_mock.return_value.get handler_get.side_effect = exception.ResourceNotFound( name='language_pack', image_id='test_id') language_pack_obj = language_pack.LanguagePackController('test_id') language_pack_obj.get() self.assertEqual(404, resp_mock.status) handler_get.assert_called_once_with('test_id')
def test_app_delete_notfound(self, AppHandler, resp_mock, request_mock): hand_delete = AppHandler.return_value.delete hand_delete.side_effect = exception.ResourceNotFound( name='missing_app', app_id='test_id') obj = app.AppController('test_id') obj.delete() hand_delete.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_sensor_get_not_found(self, handler_mock, resp_mock, request_mock): handler_get = handler_mock.return_value.get handler_get.side_effect = exception.ResourceNotFound( name='sensor', sensor_id='test_id') obj = controller.SensorController('test_id') obj.get() self.assertEqual(404, resp_mock.status) handler_get.assert_called_once_with('test_id')
def test_assembly_delete_not_found(self, AssemblyHandler, resp_mock, request_mock): hand_delete = AssemblyHandler.return_value.delete hand_delete.side_effect = exception.ResourceNotFound( name='assembly', assembly_id='test_id') obj = assembly.AssemblyController('test_id') obj.delete() hand_delete.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_stack_delete_not_found(self, StackHandler, resp_mock, request_mock): hand_delete = StackHandler.return_value.delete hand_delete.side_effect = exception.ResourceNotFound(id='test_id', name='stack') obj = infrastructure.InfrastructureStackController('test_id') obj.delete() hand_delete.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_operation_get_not_found(self, OperationHandler, resp_mock, request_mock): hand_get = OperationHandler.return_value.get hand_get.side_effect = exception.ResourceNotFound(id='test_id', name='operation') cont = operation.OperationController('test_id') cont.get() hand_get.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_language_pack_delete_not_found(self, LanguagePackHandler, resp_mock, request_mock): hand_delete = LanguagePackHandler.return_value.delete hand_delete.side_effect = exception.ResourceNotFound( name='language_pack', language_pack_id='test_id') obj = language_pack.LanguagePackController('test_id') obj.delete() hand_delete.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_pipeline_get_not_found(self, PipelineHandler, resp_mock, request_mock, mock_policy): mock_policy.return_value = True hand_get = PipelineHandler.return_value.get hand_get.side_effect = exception.ResourceNotFound( name='pipeline', pipeline_id='test_id') pipeline.PipelineController('test_id').get() hand_get.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_operation_delete_not_found(self, OperationHandler, resp_mock, request_mock): hand_delete = OperationHandler.return_value.delete hand_delete.side_effect = exception.ResourceNotFound(id='test_id', name='operation') obj = operation.OperationController('test_id') obj.delete() hand_delete.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_assembly_get_not_found(self, AssemblyHandler, resp_mock, request_mock): hand_get = AssemblyHandler.return_value.get hand_get.side_effect = exception.ResourceNotFound( name='assembly', assembly_id='test_id') cont = assembly.AssemblyController('test_id') cont.get() hand_get.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_service_delete_not_found(self, ServiceHandler, resp_mock, request_mock): hand_delete = ServiceHandler.return_value.delete hand_delete.side_effect = exception.ResourceNotFound( name='service', service_id='test_id') obj = service.ServiceController('test_id') obj.delete() hand_delete.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_sensor_delete_not_found(self, mock_handler, resp_mock, request_mock): handler_delete = mock_handler.return_value.delete handler_delete.side_effect = exception.ResourceNotFound( name='sensor', sensor_id='test_id') obj = controller.SensorController('test_id') obj.delete() handler_delete.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_stack_put_not_found(self, StackHandler, resp_mock, request_mock): json_update = {'name': 'foo'} request_mock.body = json.dumps(json_update) request_mock.content_type = 'application/json' hand_update = StackHandler.return_value.update hand_update.side_effect = exception.ResourceNotFound(id='test_id', name='stack') infrastructure.InfrastructureStackController('test_id').put() hand_update.assert_called_with('test_id', json_update) self.assertEqual(404, resp_mock.status)
def test_component_delete_not_found(self, ComponentHandler, resp_mock, request_mock, mock_policy): mock_policy.return_value = True hand_delete = ComponentHandler.return_value.delete hand_delete.side_effect = exception.ResourceNotFound( name='component', component_id='test_id') obj = component.ComponentController('test_id') obj.delete() hand_delete.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_plan_get_not_found_yaml(self, PlanHandler, resp_mock, request_mock, mock_policy): mock_policy.return_value = True request_mock.accept = 'application/x-yaml' hand_get = PlanHandler.return_value.get hand_get.side_effect = exception.ResourceNotFound(name='plan', id='test_id') plan.PlanController('test_id').get() hand_get.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_languagepack_create(self, mock_lp_build, mock_img): data = {'name': 'new app', 'source_uri': 'git://example.com/foo'} fi = fakes.FakeImage() mock_img.get_lp_by_name_or_uuid.side_effect = exc.ResourceNotFound() mock_img.return_value = fi handler = language_pack_handler.LanguagePackHandler(self.ctx) res = handler.create(data, lp_metadata=None) mock_lp_build.assert_called_once_with(res) fi.update.assert_called_once_with(data) fi.create.assert_called_once_with(self.ctx)
def test_sensor_put_not_found(self, handler_mock, resp_mock, request_mock): json_update = {'name': 'hb42', 'value': '0'} request_mock.body = json.dumps(json_update) request_mock.content_type = 'application/json' handler_update = handler_mock.return_value.update handler_update.side_effect = exception.ResourceNotFound( name='sensor', sensor_id='test_id') controller.SensorController('test_id').put() handler_update.assert_called_with('test_id', json_update) self.assertEqual(404, resp_mock.status)
def test_service_get_not_found(self, ServiceHandler, resp_mock, request_mock, mock_policy): mock_policy.return_value = True hand_get = ServiceHandler.return_value.get hand_get.side_effect = exception.ResourceNotFound(name='service', service_id='test_id') cont = service.ServiceController('test_id') cont.get() hand_get.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_extension_get_not_found(self, handler_mock, resp_mock, request_mock, mock_policy): mock_policy.return_value = True handler_get = handler_mock.return_value.get handler_get.side_effect = exception.ResourceNotFound( name='extension', extension_id='test_id') obj = controller.ExtensionController('test_id') obj.get() self.assertEqual(404, resp_mock.status) handler_get.assert_called_once_with('test_id')
def test_extension_delete_not_found(self, mock_handler, resp_mock, request_mock, mock_policy): mock_policy.return_value = True handler_delete = mock_handler.return_value.delete handler_delete.side_effect = exception.ResourceNotFound( name='extension', extension_id='test_id') obj = controller.ExtensionController('test_id') obj.delete() handler_delete.assert_called_with('test_id') self.assertEqual(404, resp_mock.status)
def test_pipeline_put_not_found(self, PipelineHandler, resp_mock, request_mock): json_update = {'name': 'foo'} request_mock.body = json.dumps(json_update) request_mock.content_type = 'application/json' hand_update = PipelineHandler.return_value.update hand_update.side_effect = exception.ResourceNotFound( name='pipeline', pipeline_id='test_id') pipeline.PipelineController('test_id').put() hand_update.assert_called_with('test_id', json_update) self.assertEqual(404, resp_mock.status)
def test_plan_put_not_found(self, PlanHandler, resp_mock, request_mock): data = 'version: 1\nname: ex_plan1\ndescription: dsc1.' request_mock.body = data request_mock.content_type = 'application/x-yaml' hand_update = PlanHandler.return_value.update hand_update.side_effect = exception.ResourceNotFound( name='plan', id='test_id') plan.PlanController('test_id').put() hand_update.assert_called_with('test_id', {'name': 'ex_plan1', 'description': u'dsc1.'}) self.assertEqual(404, resp_mock.status)