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.NotFound(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.NotFound(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_component_delete_not_found(self, ComponentHandler, resp_mock, request_mock): hand_delete = ComponentHandler.return_value.delete hand_delete.side_effect = exception.NotFound(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_component_get_not_found(self, ComponentHandler, resp_mock, request_mock): hand_get = ComponentHandler.return_value.get hand_get.side_effect = exception.NotFound(name='component', component_id='test_id') cont = component.ComponentController('test_id') cont.get() hand_get.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.NotFound(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_get_not_found(self, ServiceHandler, resp_mock, request_mock): hand_get = ServiceHandler.return_value.get hand_get.side_effect = exception.NotFound(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_sensor_delete_not_found(self, mock_handler, resp_mock, request_mock): handler_delete = mock_handler.return_value.delete handler_delete.side_effect = exception.NotFound(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_service_delete_not_found(self, ServiceHandler, resp_mock, request_mock): hand_delete = ServiceHandler.return_value.delete hand_delete.side_effect = exception.NotFound( 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_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.NotFound(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_component_put_not_found(self, ComponentHandler, resp_mock, request_mock): json_update = {'user_id': 'foo', 'name': 'appy'} request_mock.body = json.dumps(json_update) request_mock.content_type = 'application/json' hand_update = ComponentHandler.return_value.update hand_update.side_effect = exception.NotFound(name='component', component_id='test_id') component.ComponentController('test_id').put() hand_update.assert_called_with('test_id', json_update) self.assertEqual(404, resp_mock.status)
def test_assembly_put_not_found(self, AssemblyHandler, resp_mock, request_mock): json_update = {'name': 'foo'} request_mock.body = json.dumps(json_update) request_mock.content_type = 'application/json' hand_update = AssemblyHandler.return_value.update hand_update.side_effect = exception.NotFound(name='assembly', assembly_id='test_id') assembly.AssemblyController('test_id').put() hand_update.assert_called_with('test_id', json_update) self.assertEqual(404, resp_mock.status)
def test_not_found(self): exc = exception.NotFound() self.assertIn('could not be found', str(exc)) self.assertEqual(exc.code, 404)
def _raise_not_found(cls, item_id): """Raise a not found exception.""" raise exception.NotFound(name='service', id=item_id)
def test_with_kwargs_ru(self): exc = exception.NotFound(name='application', id=u'зеленой_краской') self.assertIn(u'зеленой_краской could not be found', six.text_type(exc)) self.assertEqual(exc.code, 404)
def test_with_kwargs(self): exc = exception.NotFound(name='application', id='green_paint') self.assertIn('green_paint could not be found.', six.text_type(exc)) self.assertEqual(exc.code, 404)
def _raise_not_found(cls, item_id): """Raise a not found exception.""" raise exception.NotFound(name='language_pack', id=item_id)
def _raise_not_found(cls, item_id): """Raise a not found exception.""" raise exception.NotFound(name='component', component_id=item_id)
def _raise_not_found(cls, item_id): """Raise a not found exception.""" raise exception.NotFound(name='extension', id=item_id)
def test_bad_kwargs(self): cfg.CONF.set_override('fatal_exception_format_errors', False) exc = exception.NotFound(a_field='green') self.assertIn('An unknown exception occurred', six.text_type(exc)) self.assertEqual(exc.code, 404)