-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(serializers): uncomment code chore(serializers): remove duplicated class chore(migrations): make new migrations chore(tagging): rename tagList to tags chore(serializers): add docstring chore(migrations): delete migrations feat(migrations): update migrations
- Loading branch information
1 parent
67e5f0a
commit f28e4ad
Showing
9 changed files
with
147 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 2.1 on 2018-12-19 11:00 | ||
|
||
from django.db import migrations | ||
import taggit.managers | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('taggit', '0002_auto_20150616_2121'), | ||
('articles', '0003_auto_20181218_2105'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='article', | ||
name='tags', | ||
field=taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from rest_framework import status | ||
from .base_test import BaseTestCase | ||
|
||
class TestArticleTagging(BaseTestCase): | ||
""" | ||
Test class for article tagging. | ||
""" | ||
def test_successful_tagging_article(self): | ||
""" | ||
Test method for successful article tagging. | ||
""" | ||
saved_article = self.create_article()[1] | ||
self.assertEqual(saved_article.status_code, status.HTTP_201_CREATED) | ||
self.assertEqual(saved_article.data['title'], self.article_data['article']['title']) | ||
|
||
def test_tagging_without_authentication_fails(self): | ||
""" | ||
Test for tagging without authentication. | ||
""" | ||
self.user_signup() | ||
response = self.test_client.post(self.articles_url, self.article_invalid_data, format='json') | ||
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) | ||
|
||
def test_empty_tag_list_field_is_allowed(self): | ||
""" | ||
Test that a blank tag list is allowed. | ||
""" | ||
data = { | ||
"article": { | ||
"title": "Hello world", | ||
"description": "Ever wonder how?", | ||
"body": "You have to believe", | ||
"tagList": [] | ||
} | ||
} | ||
self.user_signup() | ||
token = 'Token ' + self.user_login() | ||
response = self.test_client.post(self.articles_url, | ||
data, format='json', | ||
HTTP_AUTHORIZATION=token) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_201_CREATED) | ||
|
||
def test_non_list_tagList_data_fails(self): | ||
""" | ||
Test that non list type of data for tag is not allowed. | ||
""" | ||
data = { | ||
"article": { | ||
"title": "Hello world", | ||
"description": "Ever wonder how?", | ||
"body": "You have to believe", | ||
"tags": "hello, world" | ||
} | ||
} | ||
self.user_signup() | ||
token = 'Token ' + self.user_login() | ||
response = self.test_client.post(self.articles_url, | ||
data, format='json', | ||
HTTP_AUTHORIZATION=token) | ||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
'authors.apps.profiles', | ||
'rest_framework_swagger', | ||
'social_django', | ||
'taggit', | ||
] | ||
|
||
MIDDLEWARE = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters