added tests for add keyword and add duplicate keyword
This commit is contained in:
@ -4,7 +4,6 @@ from cookbook.models import Keyword
|
|||||||
from cookbook.tests.views.test_views import TestViews
|
from cookbook.tests.views.test_views import TestViews
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
|
|
||||||
class TestApiKeyword(TestViews):
|
class TestApiKeyword(TestViews):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -63,6 +62,26 @@ class TestApiKeyword(TestViews):
|
|||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
self.assertEqual(response['name'], 'new')
|
self.assertEqual(response['name'], 'new')
|
||||||
|
|
||||||
|
def test_keyword_add(self):
|
||||||
|
r = self.user_client_1.post(
|
||||||
|
reverse('api:keyword-list'),
|
||||||
|
{'name': 'test'},
|
||||||
|
content_type='application/json'
|
||||||
|
)
|
||||||
|
response = json.loads(r.content)
|
||||||
|
self.assertEqual(r.status_code, 201)
|
||||||
|
self.assertEqual(response['name'], 'test')
|
||||||
|
|
||||||
|
def test_keyword_add_duplicate(self):
|
||||||
|
r = self.user_client_1.post(
|
||||||
|
reverse('api:keyword-list'),
|
||||||
|
{'name': self.keyword_1.name},
|
||||||
|
content_type='application/json'
|
||||||
|
)
|
||||||
|
response = json.loads(r.content)
|
||||||
|
self.assertEqual(r.status_code, 201)
|
||||||
|
self.assertEqual(response['name'], {self.keyword_1.name})
|
||||||
|
|
||||||
def test_keyword_delete(self):
|
def test_keyword_delete(self):
|
||||||
r = self.user_client_1.delete(
|
r = self.user_client_1.delete(
|
||||||
reverse(
|
reverse(
|
||||||
|
Reference in New Issue
Block a user