-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reading time): time taken to read an article
- add time taken to read an article - add tests for time taken [#Delivers 161254677]
- Loading branch information
Showing
3 changed files
with
87 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from django.urls import reverse | ||
from rest_framework.test import APITestCase, APIClient | ||
|
||
|
||
class TestArticleComments(APITestCase): | ||
def setUp(self): | ||
""" | ||
Prepare test environment for each testcase | ||
""" | ||
self.client = APIClient() | ||
self.author_details = { | ||
'user': { | ||
'username': 'admin123', | ||
'email': 'admin@admin.com', | ||
'password': 'admin2018', | ||
} | ||
} | ||
self.login_data = { | ||
"user": { | ||
'email': 'admin@admin.com', | ||
'password': 'admin2018', | ||
} | ||
} | ||
|
||
self.new_article = { | ||
"title": "How to train your dragon", | ||
"description": "Ever wonder how?", | ||
"body": "You have to believe" | ||
} | ||
|
||
self.login_url = reverse('authentication:login') | ||
self.signup_url = reverse('authentication:register') | ||
self.articles_url = reverse('article:create') | ||
|
||
self.client.post( | ||
self.signup_url, | ||
self.author_details, | ||
format='json') | ||
|
||
def login(self): | ||
"""login user to get the token""" | ||
response = self.client.post( | ||
self.login_url, self.login_data, format='json') | ||
return response.data.get('token') | ||
|
||
def test_time_to_read(self): | ||
"""This method tests the time taken to read an article""" |