-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- search articles by specific author/title/tags - enable article ordering using author/title - enable a general filter [Starts #162949228]
- Loading branch information
Showing
7 changed files
with
129 additions
and
17 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
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,45 @@ | ||
import json | ||
from rest_framework.views import status | ||
from django.urls import reverse | ||
|
||
# local imports | ||
from .base_test import TestBase | ||
|
||
|
||
class TestFilterSet(TestBase): | ||
|
||
def test_get_article_by_author(self): | ||
"""test_get_article_by_author """ | ||
self.verify_user() | ||
self.client.get(self.get_verify_url(self.user_data)) | ||
self.client.post( | ||
self.article_url, | ||
data=json.dumps(self.valid_article_data), | ||
content_type='application/json' | ||
) | ||
url = reverse('search') + '?author = {}'.format('sam') | ||
response = self.client.get( | ||
url, | ||
content_type='application/json' | ||
) | ||
articles = response.data['results'] | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual(len(articles), 1) | ||
|
||
def test_get_article_by_tag(self): | ||
"""test_get_article_by_tag """ | ||
self.verify_user() | ||
self.client.get(self.get_verify_url(self.user_data)) | ||
self.client.post( | ||
self.article_url, | ||
data=json.dumps(self.valid_article_data), | ||
content_type='application/json' | ||
) | ||
url = reverse('search') + '?tagList = {}'.format('young') | ||
response = self.client.get( | ||
url, | ||
content_type='application/json' | ||
) | ||
articles = response.data['results'] | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual(len(articles), 1) |
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