diff --git a/src/freeseer/frontend/controller/configuration/configuration.py b/src/freeseer/frontend/controller/configuration/configuration.py index 99f263c2..0dc6954e 100644 --- a/src/freeseer/frontend/controller/configuration/configuration.py +++ b/src/freeseer/frontend/controller/configuration/configuration.py @@ -98,12 +98,12 @@ def create_profile(): pattern = '^\w+$' profile_name = request.form['name'] if not re.match(pattern, profile_name): - raise HTTPError('Invalid Profile Name: {}'.format(profile_name), 400) + raise HTTPError(400, 'Invalid Profile Name: {}'.format(profile_name)) try: settings.profile_manager.create(profile_name) except ProfileAlreadyExists: - raise HTTPError('Profile Already Exists', 400) + raise HTTPError(400, 'Profile Already Exists') return '' @@ -119,7 +119,7 @@ def delete_profile(profile): try: settings.profile_manager.delete(profile) except ProfileDoesNotExist: - HTTPError('Profile Does Not Exist', 400) + HTTPError(400, 'Profile Does Not Exist') return '' diff --git a/src/freeseer/frontend/controller/configuration/helpers.py b/src/freeseer/frontend/controller/configuration/helpers.py index 1743850f..7118afb5 100644 --- a/src/freeseer/frontend/controller/configuration/helpers.py +++ b/src/freeseer/frontend/controller/configuration/helpers.py @@ -53,7 +53,7 @@ def map_plugin_name(plugin): try: name = plugin_names_map[plugin] except KeyError: - raise HTTPError('Invalid Plugin Name: {}'.format(plugin), 400) + raise HTTPError(400, 'Invalid Plugin Name: {}'.format(plugin)) return name @@ -67,7 +67,7 @@ def map_plugin_category(category): try: category = plugin_types_map[category] except KeyError: - raise HTTPError('Invalid Plugin Category: {}'.format(category), 400) + raise HTTPError(400, 'Invalid Plugin Category: {}'.format(category)) return category @@ -89,9 +89,9 @@ def update_config(config, data): value = opt_instance.decode(value) setattr(config, key, value) except KeyError: - raise HTTPError('Invalid Option: {}'.format(key), 400) + raise HTTPError(400, 'Invalid Option: {}'.format(key)) except InvalidOptionValueError: - raise HTTPError('Invalid Value {} for option {}'.format(value, key), 400) + raise HTTPError(400, 'Invalid Value {} for option {}'.format(value, key)) config.save() @@ -148,7 +148,7 @@ def load_profile(profile): try: profile = settings.profile_manager.get(profile, create_if_needed=False) except ProfileDoesNotExist: - raise HTTPError('Profile Does Not Exist', 404) + raise HTTPError(404, 'Profile Does Not Exist') return profile @@ -170,7 +170,7 @@ def get_plugin_config(profile, category, plugin, id): plugin_class = plugin_manager.get_plugin_by_name(map_plugin_name(plugin), map_plugin_category(category)) if not plugin_class: - raise HTTPError('No plugin {} of type {}'.format(plugin, category), 400) + raise HTTPError(400, 'No plugin {} of type {}'.format(plugin, category)) plugin_object = plugin_class.plugin_object plugin_class.plugin_object.set_instance(id) @@ -201,7 +201,7 @@ def get_plugin_instance_uids(profile, category, plugin): plugin_class = plugin_manager.get_plugin_by_name(map_plugin_name(plugin), map_plugin_category(category)) if not plugin_class: - raise HTTPError('No plugin {} of type {}'.format(plugin, category), 400) + raise HTTPError(400, 'No plugin {} of type {}'.format(plugin, category)) storage = profile_instance.get_storage('plugin.conf') parser = ConfigParser.ConfigParser() diff --git a/src/freeseer/tests/frontend/controller/test_configuration.py b/src/freeseer/tests/frontend/controller/test_configuration.py index e914c3cc..af0ad0a4 100644 --- a/src/freeseer/tests/frontend/controller/test_configuration.py +++ b/src/freeseer/tests/frontend/controller/test_configuration.py @@ -99,10 +99,10 @@ def test_create_profile(self, test_client): assert new_profile def test_create_profile_invalid_args(self, test_client): - response = test_client.post('/profiles', data={'name': '$%@DN@'}) + response = test_client.post('/profiles', data={'name': '12@345'}) data = json.loads(response.data) assert response.status_code == 400 - assert data['error_message'] == 'Invalid Profile Name: $%@DN@' + assert data['description'] == 'Invalid Profile Name: 12@345' def test_create_profile_already_exists(self, test_client): response = test_client.post('/profiles', @@ -142,10 +142,8 @@ def test_modify_profile_invalid_option(self, test_client): 'not_a_real_option': True }) response_data = json.loads(response.data) - assert response_data == { - 'error_message': 'Invalid Option: not_a_real_option', - 'error_code': 400 - } + assert response_data['description'] == 'Invalid Option: not_a_real_option' + assert response_data['error_code'] == 400 def test_view_general_configuration(self, test_client, configuration): response = test_client.get('/profiles/testing/general') @@ -244,13 +242,13 @@ def test_view_plugin_instance(self, test_client, configuration): def test_view_invalid_plugin_name(self, test_client, configuration): response = test_client.get('/profiles/testing/recording/audioinput/fakeaudiosource/0') data = json.loads(response.data) - assert data['error_message'] == 'Invalid Plugin Name: fakeaudiosource' + assert data['description'] == 'Invalid Plugin Name: fakeaudiosource' assert response.status_code == 400 def test_view_invalid_plugin_category(self, test_client, configuration): response = test_client.get('/profiles/testing/recording/fakeinput/jackaudiosource/0') data = json.loads(response.data) - assert data['error_message'] == 'Invalid Plugin Category: fakeinput' + assert data['description'] == 'Invalid Plugin Category: fakeinput' assert response.status_code == 400 def test_create_plugin_instance(self, test_client, configuration):