-
Notifications
You must be signed in to change notification settings - Fork 7
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
13 changed files
with
176 additions
and
253 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 |
---|---|---|
|
@@ -96,4 +96,3 @@ db.sqlite3 | |
.vscode/ | ||
.DS_Store | ||
*.swp | ||
migrations/ |
This file was deleted.
Oops, something went wrong.
64 changes: 0 additions & 64 deletions
64
authors/apps/articles/migrations/0002_auto_20181218_0735.py
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,59 @@ | ||
from django.test import TestCase | ||
|
||
import json | ||
from ..test.base import BaseTestArticles | ||
|
||
class TestStats(BaseTestArticles): | ||
def test_read_statistics_updated_successfully(self): | ||
self.client.credentials( | ||
HTTP_AUTHORIZATION='Bearer ' + self.login_user()) | ||
response = self.client.post( | ||
'/api/articles/', data=self.article, format='json') | ||
res = self.client.post( | ||
'/api/articles/{}/3'.format(self.create_article()), | ||
format='json') | ||
self.assertTrue(res.status_code, 200) | ||
self.assertEqual(1, res.data['read_count']) | ||
|
||
def test_user_count_for_a_read_is_only_one(self): | ||
self.client.credentials( | ||
HTTP_AUTHORIZATION='Bearer ' + self.login_user()) | ||
res = self.client.post( | ||
'/api/articles/', data=self.article, format='json') | ||
slug = res.data['slug'] | ||
self.client.post( | ||
'/api/articles/{}/3'.format(slug), | ||
format='json') | ||
resp = self.client.post( | ||
'/api/articles/{}/3'.format(slug), | ||
format='json') | ||
self.assertTrue(resp.status_code, 200) | ||
self.assertEqual(1, resp.data['read_count']) | ||
|
||
def test_a_read_cannot_be_recorded_when_user_hasnot_read_the_article(self): | ||
data = { | ||
|
||
"article": { | ||
"title": "How to train your dragon added on the titlt", | ||
"description": "Ever wonder how?", | ||
"body": "You have to believe this body has beeb updated " * 100, | ||
"tagList": ["Rails", "Golang", "magic!"], | ||
"images": [ | ||
{ | ||
"image_url": "https://imgur.comhenry/", | ||
"description": "image is cool" | ||
} | ||
] | ||
} | ||
} | ||
self.client.credentials( | ||
HTTP_AUTHORIZATION='Bearer ' + self.login_user()) | ||
resp = self.client.post( | ||
'/api/articles/', data=data, format='json') | ||
slug = resp.data['slug'] | ||
res = self.client.post( | ||
'/api/articles/{}/2'.format(slug), | ||
format='json') | ||
self.assertTrue(res.status_code, 301) | ||
self.assertEqual('read not recorded', res.data['message']) | ||
|
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
Oops, something went wrong.