Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof committed Jan 16, 2023
1 parent 9a0cfe4 commit fe7d9e8
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ APP_NAME: platzky
# - graph_ql has:
# - CMS_ENDPOINT
# - CMS_TOKEN

# Wheather it should to www or to use non-www as canonical
USE_WWW: True


DB:
TYPE: json_file
PATH: "../tests/e2e_tests/db.json"
Expand Down
32 changes: 31 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ google-cloud-storage = "^2.5.0"
[tool.poetry.group.dev.dependencies]
pytest = "^7.1.3"
coverage = "^6.4.4"
freezegun = "^1.2.2"

[build-system]
requires = ["poetry-core"]
Expand Down
67 changes: 67 additions & 0 deletions tests/unit_tests/blog/test_formatter.py
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"
1 change: 1 addition & 0 deletions tests/unit_tests/test_engine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from platzky.platzky import *


def test_engine_creation():
mapping = {'DB': {'TYPE': 'json_file',
"PATH": "./tests/e2e_tests/db.json"}}
Expand Down

0 comments on commit fe7d9e8

Please sign in to comment.