Skip to content

Commit

Permalink
Merge pull request #19 from /issues/9
Browse files Browse the repository at this point in the history
Add more unit test to better cover the put and delete endpoints. Closes #9.
  • Loading branch information
chambridge committed Sep 12, 2017
2 parents 8533f1a + eec5665 commit 2116b5e
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion quipucords/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#
"""Test the API application"""

import json
from django.test import TestCase
from django.core.urlresolvers import reverse
from rest_framework import status
Expand Down Expand Up @@ -64,5 +65,27 @@ def test_hostcred_list_view(self):
"""Tests the list view set of the HostCredential API"""
url = reverse("hostcred-list")
resp = self.client.get(url)
self.assertEqual(resp.status_code, status.HTTP_200_OK)

self.assertEqual(resp.status_code, 200)
def test_hostcred_update_view(self):
"""Tests the update view set of the HostCredential API"""
cred = models.HostCredential(name='cred2', username='user2',
password='pass2')
cred.save()
data = {'name': 'cred2',
'username': 'user2',
'password': 'pass3'}
url = reverse("hostcred-detail", args=(cred.pk,))
resp = self.client.put(url, json.dumps(data),
content_type='application/json',
format='json')
self.assertEqual(resp.status_code, status.HTTP_200_OK)

def test_hostcred_delete_view(self):
"""Tests the delete view set of the HostCredential API"""
cred = models.HostCredential(name='cred2', username='user2',
password='pass2')
cred.save()
url = reverse("hostcred-detail", args=(cred.pk,))
resp = self.client.delete(url, format='json')
self.assertEqual(resp.status_code, status.HTTP_204_NO_CONTENT)

0 comments on commit 2116b5e

Please sign in to comment.