-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement user can see readtime of an article (#35)
- write tests to calculate read time of an article - add function tp calculate read time of an article in utils - add readtime to article serializer - move test data for readtime to test data file [Starts #163383193]
- Loading branch information
Showing
5 changed files
with
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from rest_framework import status | ||
from authors.apps.articles.tests import base_class | ||
from ..utils.utils import get_article_read_time | ||
from .test_data import test_article_data | ||
|
||
|
||
class TestArticleReadTime(base_class.BaseTest): | ||
"""Class tests calculation of read time of an article""" | ||
|
||
def test_calculate_readtime(self): | ||
read_time = get_article_read_time( | ||
test_article_data.one_min_read_text | ||
) | ||
self.assertIn("1 min read", read_time) | ||
|
||
def test_calculate_readtime_empty_body(self): | ||
read_time = get_article_read_time( | ||
test_article_data.zero_min_read_text | ||
) | ||
self.assertIn("0 min read", read_time) |
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