Skip to content

Commit a044e94

Browse files
committed
fix(scale): return a 404 instead of 400 when scale uses a proc type that does not exist
Fixes #830
1 parent 269170c commit a044e94

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

rootfs/api/models/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def scale(self, user, structure): # noqa
379379
continue # allow docker cmd types in case we don't have the image source
380380

381381
if container_type not in available_process_types:
382-
raise DeisException(
382+
raise NotFound(
383383
'Container type {} does not exist in application'.format(container_type))
384384

385385
# merge current structure and the new items together

rootfs/api/tests/deployments/test_pods.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def test_container_errors(self, mock_requests):
304304
"int() with base 10: 'not_an_int'"})
305305
body = {'invalid': 1}
306306
response = self.client.post(url, body)
307-
self.assertContains(response, 'Container type invalid', status_code=400)
307+
self.assertContains(response, 'Container type invalid', status_code=404)
308308

309309
def test_container_str(self, mock_requests):
310310
"""Test the text representation of a container."""
@@ -437,6 +437,12 @@ def test_scale_errors(self, mock_requests):
437437
response = self.client.post(url, body)
438438
self.assertEqual(response.status_code, 400, response.data)
439439

440+
# scale with a non-existent proc type
441+
url = "/v2/apps/{app_id}/scale".format(**locals())
442+
body = {'foo': 1}
443+
response = self.client.post(url, body)
444+
self.assertEqual(response.status_code, 404, response.data)
445+
440446
# scale up to an integer as a sanity check
441447
url = "/v2/apps/{app_id}/scale".format(**locals())
442448
body = {'web': 1}

rootfs/api/tests/test_pods.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def test_container_errors(self, mock_requests):
302302
"int() with base 10: 'not_an_int'"})
303303
body = {'invalid': 1}
304304
response = self.client.post(url, body)
305-
self.assertContains(response, 'Container type invalid', status_code=400)
305+
self.assertContains(response, 'Container type invalid', status_code=404)
306306

307307
def test_container_str(self, mock_requests):
308308
"""Test the text representation of a container."""
@@ -435,6 +435,12 @@ def test_scale_errors(self, mock_requests):
435435
response = self.client.post(url, body)
436436
self.assertEqual(response.status_code, 400, response.data)
437437

438+
# scale with a non-existent proc type
439+
url = "/v2/apps/{app_id}/scale".format(**locals())
440+
body = {'foo': 1}
441+
response = self.client.post(url, body)
442+
self.assertEqual(response.status_code, 404, response.data)
443+
438444
# scale up to an integer as a sanity check
439445
url = "/v2/apps/{app_id}/scale".format(**locals())
440446
body = {'web': 1}

0 commit comments

Comments
 (0)