-
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.
- Loading branch information
Krzysztof
committed
Jan 16, 2023
1 parent
9a0cfe4
commit fe7d9e8
Showing
5 changed files
with
105 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from platzky.blog.post_formatter import format_post, get_delta | ||
from datetime import datetime | ||
from freezegun import freeze_time | ||
|
||
|
||
@freeze_time("2022-01-01") | ||
def test_post_formatting(): | ||
post = { | ||
"title": "title", | ||
"language": "en", | ||
"slug": "slug", | ||
"tags": [ | ||
"tag/1" | ||
], | ||
"contentInRichText": { | ||
"markdown": "content" | ||
}, | ||
"date": "2021-02-19", | ||
"coverImage": { | ||
"alternateText": "text which is alternative", | ||
"image": { | ||
"url": "https://media.graphcms.com/XvmCDUjYTIq4c9wOIseo" | ||
} | ||
}, | ||
"comments": [ | ||
{ | ||
"date": "2021-02-19T00:00:00", | ||
"comment": "komentarz", | ||
"author": "autor" | ||
} | ||
] | ||
} | ||
|
||
wanted_post = { | ||
"title": "title", | ||
"language": "en", | ||
"slug": "slug", | ||
"tags": [ | ||
"tag/1" | ||
], | ||
"contentInRichText": { | ||
"markdown": "content" | ||
}, | ||
"date": "2021-02-19", | ||
"coverImage": { | ||
"alternateText": "text which is alternative", | ||
"image": { | ||
"url": "https://media.graphcms.com/XvmCDUjYTIq4c9wOIseo" | ||
} | ||
}, | ||
"comments": [ | ||
{ | ||
"time_delta": "10 months ago", | ||
"date": "2021-02-19T00:00:00", | ||
"comment": "komentarz", | ||
"author": "autor" | ||
} | ||
] | ||
} | ||
|
||
assert format_post(post) == wanted_post | ||
|
||
|
||
def test_time_delta(): | ||
now_date = datetime.strptime("2022-11-01T00:00:00", "%Y-%m-%dT%H:%M:%S") | ||
delta = get_delta(now_date, "2022-11-02T00:00:00") | ||
assert delta == "a day from now" |
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