-
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.
- Loading branch information
Showing
6 changed files
with
116 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from rest_framework import status | ||
from .base_test import BaseTestCase | ||
from django.urls import reverse | ||
|
||
|
||
class TestArticles(BaseTestCase): | ||
"class to test making an article a favorite" | ||
|
||
def test_favorite(self): | ||
"""test for favoriting an article""" | ||
self.user_signup() | ||
token = self.user_login() | ||
response = self.client.put(self.favorite_article(), format='json', HTTP_AUTHORIZATION='Token ' + token) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual(response.data, {'You have favorited this article'}) | ||
|
||
def unfavorite_article(self): | ||
"""test for favoriting an article that does not exist""" | ||
self.user_signup() | ||
token = self.user_login() | ||
response = self.client.put(self.unfavorite_article(), format='json', HTTP_AUTHORIZATION='Token ' + token) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual(response.data, {'You have removed this article from your favorites'}) | ||
|
||
def non_existing_article(self): | ||
"""test for favoriting an article that does not exist""" | ||
self.user_signup() | ||
token = self.user_login() | ||
response = self.client.put(self.favoritearticle_url, format='json', HTTP_AUTHORIZATION='Token ' + token) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual(response.data, {'You have removed this article from your favorites'}) |
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