|
12 | 12 | from django.test import TestCase |
13 | 13 | from rest_framework.authtoken.models import Token |
14 | 14 |
|
| 15 | +from api.models import Domain |
| 16 | + |
15 | 17 |
|
16 | 18 | class DomainTest(TestCase): |
17 | 19 |
|
@@ -78,6 +80,26 @@ def test_manage_domain(self): |
78 | 80 | HTTP_AUTHORIZATION='token {}'.format(self.token)) |
79 | 81 | self.assertEqual(0, response.data['count'], msg) |
80 | 82 |
|
| 83 | + def test_delete_domain_does_not_remove_latest(self): |
| 84 | + """https://github.com/deis/deis/issues/3239""" |
| 85 | + url = '/v1/apps/{app_id}/domains'.format(app_id=self.app_id) |
| 86 | + test_domains = [ |
| 87 | + 'test-domain.example.com', |
| 88 | + 'django.paas-sandbox', |
| 89 | + ] |
| 90 | + for domain in test_domains: |
| 91 | + body = {'domain': domain} |
| 92 | + response = self.client.post(url, json.dumps(body), content_type='application/json', |
| 93 | + HTTP_AUTHORIZATION='token {}'.format(self.token)) |
| 94 | + self.assertEqual(response.status_code, 201) |
| 95 | + url = '/v1/apps/{app_id}/domains/{domain}'.format(domain=test_domains[0], |
| 96 | + app_id=self.app_id) |
| 97 | + response = self.client.delete(url, content_type='application/json', |
| 98 | + HTTP_AUTHORIZATION='token {}'.format(self.token)) |
| 99 | + self.assertEqual(response.status_code, 204) |
| 100 | + with self.assertRaises(Domain.DoesNotExist): |
| 101 | + Domain.objects.get(domain=test_domains[0]) |
| 102 | + |
81 | 103 | def test_manage_domain_invalid_app(self): |
82 | 104 | url = '/v1/apps/{app_id}/domains'.format(app_id="this-app-does-not-exist") |
83 | 105 | body = {'domain': 'test-domain.example.com'} |
|
0 commit comments