Skip to content

Commit

Permalink
Merge pull request deis#3308 from bacongobbler/3239-domain-removes-la…
Browse files Browse the repository at this point in the history
…test

fix(controller): retrieve requested domain from .get_object
  • Loading branch information
Matthew Fisher committed Mar 17, 2015
2 parents 7d04f3a + f934dbe commit eeab1df
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
22 changes: 22 additions & 0 deletions controller/api/tests/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from django.test import TestCase
from rest_framework.authtoken.models import Token

from api.models import Domain


class DomainTest(TestCase):

Expand Down Expand Up @@ -78,6 +80,26 @@ def test_manage_domain(self):
HTTP_AUTHORIZATION='token {}'.format(self.token))
self.assertEqual(0, response.data['count'], msg)

def test_delete_domain_does_not_remove_latest(self):
"""https://github.com/deis/deis/issues/3239"""
url = '/v1/apps/{app_id}/domains'.format(app_id=self.app_id)
test_domains = [
'test-domain.example.com',
'django.paas-sandbox',
]
for domain in test_domains:
body = {'domain': domain}
response = self.client.post(url, json.dumps(body), content_type='application/json',
HTTP_AUTHORIZATION='token {}'.format(self.token))
self.assertEqual(response.status_code, 201)
url = '/v1/apps/{app_id}/domains/{domain}'.format(domain=test_domains[0],
app_id=self.app_id)
response = self.client.delete(url, content_type='application/json',
HTTP_AUTHORIZATION='token {}'.format(self.token))
self.assertEqual(response.status_code, 204)
with self.assertRaises(Domain.DoesNotExist):
Domain.objects.get(domain=test_domains[0])

def test_manage_domain_invalid_app(self):
url = '/v1/apps/{app_id}/domains'.format(app_id="this-app-does-not-exist")
body = {'domain': 'test-domain.example.com'}
Expand Down
3 changes: 3 additions & 0 deletions controller/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ class DomainViewSet(AppResourceViewSet):
model = models.Domain
serializer_class = serializers.DomainSerializer

def get_object(self, **kwargs):
return self.get_queryset(**kwargs)


class KeyViewSet(BaseDeisViewSet):
"""A viewset for interacting with Key objects."""
Expand Down

0 comments on commit eeab1df

Please sign in to comment.