Skip to content
This repository was archived by the owner on May 28, 2022. It is now read-only.

Commit 6911125

Browse files
Updates HTTPError calls to changes on master
1 parent ee2e704 commit 6911125

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

src/freeseer/frontend/controller/configuration/configuration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ def create_profile():
9898
pattern = '^\w+$'
9999
profile_name = request.form['name']
100100
if not re.match(pattern, profile_name):
101-
raise HTTPError('Invalid Profile Name: {}'.format(profile_name), 400)
101+
raise HTTPError(400, 'Invalid Profile Name: {}'.format(profile_name))
102102

103103
try:
104104
settings.profile_manager.create(profile_name)
105105
except ProfileAlreadyExists:
106-
raise HTTPError('Profile Already Exists', 400)
106+
raise HTTPError(400, 'Profile Already Exists')
107107
return ''
108108

109109

@@ -119,7 +119,7 @@ def delete_profile(profile):
119119
try:
120120
settings.profile_manager.delete(profile)
121121
except ProfileDoesNotExist:
122-
HTTPError('Profile Does Not Exist', 400)
122+
HTTPError(400, 'Profile Does Not Exist')
123123
return ''
124124

125125

src/freeseer/frontend/controller/configuration/helpers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def map_plugin_name(plugin):
5353
try:
5454
name = plugin_names_map[plugin]
5555
except KeyError:
56-
raise HTTPError('Invalid Plugin Name: {}'.format(plugin), 400)
56+
raise HTTPError(400, 'Invalid Plugin Name: {}'.format(plugin))
5757
return name
5858

5959

@@ -67,7 +67,7 @@ def map_plugin_category(category):
6767
try:
6868
category = plugin_types_map[category]
6969
except KeyError:
70-
raise HTTPError('Invalid Plugin Category: {}'.format(category), 400)
70+
raise HTTPError(400, 'Invalid Plugin Category: {}'.format(category))
7171
return category
7272

7373

@@ -89,9 +89,9 @@ def update_config(config, data):
8989
value = opt_instance.decode(value)
9090
setattr(config, key, value)
9191
except KeyError:
92-
raise HTTPError('Invalid Option: {}'.format(key), 400)
92+
raise HTTPError(400, 'Invalid Option: {}'.format(key))
9393
except InvalidOptionValueError:
94-
raise HTTPError('Invalid Value {} for option {}'.format(value, key), 400)
94+
raise HTTPError(400, 'Invalid Value {} for option {}'.format(value, key))
9595
config.save()
9696

9797

@@ -148,7 +148,7 @@ def load_profile(profile):
148148
try:
149149
profile = settings.profile_manager.get(profile, create_if_needed=False)
150150
except ProfileDoesNotExist:
151-
raise HTTPError('Profile Does Not Exist', 404)
151+
raise HTTPError(404, 'Profile Does Not Exist')
152152
return profile
153153

154154

@@ -170,7 +170,7 @@ def get_plugin_config(profile, category, plugin, id):
170170
plugin_class = plugin_manager.get_plugin_by_name(map_plugin_name(plugin),
171171
map_plugin_category(category))
172172
if not plugin_class:
173-
raise HTTPError('No plugin {} of type {}'.format(plugin, category), 400)
173+
raise HTTPError(400, 'No plugin {} of type {}'.format(plugin, category))
174174

175175
plugin_object = plugin_class.plugin_object
176176
plugin_class.plugin_object.set_instance(id)
@@ -201,7 +201,7 @@ def get_plugin_instance_uids(profile, category, plugin):
201201
plugin_class = plugin_manager.get_plugin_by_name(map_plugin_name(plugin),
202202
map_plugin_category(category))
203203
if not plugin_class:
204-
raise HTTPError('No plugin {} of type {}'.format(plugin, category), 400)
204+
raise HTTPError(400, 'No plugin {} of type {}'.format(plugin, category))
205205

206206
storage = profile_instance.get_storage('plugin.conf')
207207
parser = ConfigParser.ConfigParser()

src/freeseer/tests/frontend/controller/test_configuration.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ def test_create_profile(self, test_client):
9999
assert new_profile
100100

101101
def test_create_profile_invalid_args(self, test_client):
102-
response = test_client.post('/profiles', data={'name': '$%@DN@'})
102+
response = test_client.post('/profiles', data={'name': '12@345'})
103103
data = json.loads(response.data)
104104
assert response.status_code == 400
105-
assert data['error_message'] == 'Invalid Profile Name: $%@DN@'
105+
assert data['description'] == 'Invalid Profile Name: 12@345'
106106

107107
def test_create_profile_already_exists(self, test_client):
108108
response = test_client.post('/profiles',
@@ -142,10 +142,8 @@ def test_modify_profile_invalid_option(self, test_client):
142142
'not_a_real_option': True
143143
})
144144
response_data = json.loads(response.data)
145-
assert response_data == {
146-
'error_message': 'Invalid Option: not_a_real_option',
147-
'error_code': 400
148-
}
145+
assert response_data['description'] == 'Invalid Option: not_a_real_option'
146+
assert response_data['error_code'] == 400
149147

150148
def test_view_general_configuration(self, test_client, configuration):
151149
response = test_client.get('/profiles/testing/general')
@@ -244,13 +242,13 @@ def test_view_plugin_instance(self, test_client, configuration):
244242
def test_view_invalid_plugin_name(self, test_client, configuration):
245243
response = test_client.get('/profiles/testing/recording/audioinput/fakeaudiosource/0')
246244
data = json.loads(response.data)
247-
assert data['error_message'] == 'Invalid Plugin Name: fakeaudiosource'
245+
assert data['description'] == 'Invalid Plugin Name: fakeaudiosource'
248246
assert response.status_code == 400
249247

250248
def test_view_invalid_plugin_category(self, test_client, configuration):
251249
response = test_client.get('/profiles/testing/recording/fakeinput/jackaudiosource/0')
252250
data = json.loads(response.data)
253-
assert data['error_message'] == 'Invalid Plugin Category: fakeinput'
251+
assert data['description'] == 'Invalid Plugin Category: fakeinput'
254252
assert response.status_code == 400
255253

256254
def test_create_plugin_instance(self, test_client, configuration):

0 commit comments

Comments
 (0)