Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
fix(scale): return a 404 instead of 400 when scale uses a proc type t…
Browse files Browse the repository at this point in the history
…hat does not exist

Fixes #830
  • Loading branch information
helgi committed Aug 1, 2016
1 parent 269170c commit a044e94
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rootfs/api/models/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def scale(self, user, structure): # noqa
continue # allow docker cmd types in case we don't have the image source

if container_type not in available_process_types:
raise DeisException(
raise NotFound(
'Container type {} does not exist in application'.format(container_type))

# merge current structure and the new items together
Expand Down
8 changes: 7 additions & 1 deletion rootfs/api/tests/deployments/test_pods.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def test_container_errors(self, mock_requests):
"int() with base 10: 'not_an_int'"})
body = {'invalid': 1}
response = self.client.post(url, body)
self.assertContains(response, 'Container type invalid', status_code=400)
self.assertContains(response, 'Container type invalid', status_code=404)

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

# scale with a non-existent proc type
url = "/v2/apps/{app_id}/scale".format(**locals())
body = {'foo': 1}
response = self.client.post(url, body)
self.assertEqual(response.status_code, 404, response.data)

# scale up to an integer as a sanity check
url = "/v2/apps/{app_id}/scale".format(**locals())
body = {'web': 1}
Expand Down
8 changes: 7 additions & 1 deletion rootfs/api/tests/test_pods.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def test_container_errors(self, mock_requests):
"int() with base 10: 'not_an_int'"})
body = {'invalid': 1}
response = self.client.post(url, body)
self.assertContains(response, 'Container type invalid', status_code=400)
self.assertContains(response, 'Container type invalid', status_code=404)

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

# scale with a non-existent proc type
url = "/v2/apps/{app_id}/scale".format(**locals())
body = {'foo': 1}
response = self.client.post(url, body)
self.assertEqual(response.status_code, 404, response.data)

# scale up to an integer as a sanity check
url = "/v2/apps/{app_id}/scale".format(**locals())
body = {'web': 1}
Expand Down

0 comments on commit a044e94

Please sign in to comment.