|
17 | 17 | from rest_framework.authtoken.models import Token |
18 | 18 |
|
19 | 19 | from api.models import App, Config |
20 | | -from scheduler import KubeException |
| 20 | +from scheduler import KubeException, KubeHTTPException |
21 | 21 |
|
22 | 22 | from api.exceptions import DeisException |
23 | 23 | from api.tests import adapter, mock_port, DeisTestCase |
@@ -101,7 +101,7 @@ def test_app_logs(self, mock_requests, mock_get): |
101 | 101 | response = self.client.get(url) |
102 | 102 | self.assertEqual(response.status_code, 204, response.content) |
103 | 103 |
|
104 | | - # test logs - 404 from deis-logger |
| 104 | + # test logs - from deis-logger |
105 | 105 | mock_response.status_code = 404 |
106 | 106 | response = self.client.get(url) |
107 | 107 | self.assertEqual(response.status_code, 204, response.content) |
@@ -405,6 +405,33 @@ def test_app_delete_failure_kubernetes_destroy(self, mock_requests): |
405 | 405 | response = self.client.delete('/v2/apps/{}'.format(app_id)) |
406 | 406 | self.assertEqual(response.status_code, 503, response.data) |
407 | 407 |
|
| 408 | + def test_app_delete_missing_namespace(self, mock_requests): |
| 409 | + """ |
| 410 | + Create an app and then delete but have namespace missing |
| 411 | + Should still succeed |
| 412 | + """ |
| 413 | + # create |
| 414 | + app_id = self.create_app() |
| 415 | + |
| 416 | + with mock.patch('scheduler.resources.namespace.Namespace.get') as mock_kube: |
| 417 | + # instead of full request mocking, fake it out in a simple way |
| 418 | + class Response(object): |
| 419 | + def json(self): |
| 420 | + return '{}' |
| 421 | + |
| 422 | + response = Response() |
| 423 | + response.status_code = 404 |
| 424 | + response.reason = "Not Found" |
| 425 | + kube_exception = KubeHTTPException(response, 'big boom') |
| 426 | + mock_kube.side_effect = kube_exception |
| 427 | + |
| 428 | + response = self.client.delete('/v2/apps/{}'.format(app_id)) |
| 429 | + self.assertEqual(response.status_code, 204, response.data) |
| 430 | + |
| 431 | + # verify that app is gone |
| 432 | + response = self.client.get('/v2/apps/{}'.format(app_id)) |
| 433 | + self.assertEqual(response.status_code, 404, response.data) |
| 434 | + |
408 | 435 | def test_app_verify_application_health_success(self, mock_requests): |
409 | 436 | """ |
410 | 437 | Create an application which in turn causes a health check to run against |
|
0 commit comments