Skip to content
This repository was archived by the owner on Oct 29, 2022. It is now read-only.

Commit fe99d65

Browse files
committed
format with black via pre-commit
1 parent fb3fd02 commit fe99d65

File tree

6 files changed

+47
-37
lines changed

6 files changed

+47
-37
lines changed

automation/archive.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
import pathlib
44
from datetime import datetime, timedelta
55

6-
from jinja2 import Environment, FileSystemLoader
7-
86
from engine import engine
97
from issues import get_issues_from_github
8+
from jinja2 import Environment, FileSystemLoader
109

1110
# Get the date of the next friday
1211

automation/tests/conftest.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
import pytest
21
import datetime
32
import random
43

4+
import pytest
5+
6+
57
@pytest.fixture(scope="session")
68
def date():
79
return datetime.datetime.today()
810

11+
912
@pytest.fixture(scope="session")
1013
def time():
11-
return datetime.time(hour=random.randint(0, 23), minute=random.randint(0, 59), second=random.randint(0, 59))
14+
return datetime.time(
15+
hour=random.randint(0, 23),
16+
minute=random.randint(0, 59),
17+
second=random.randint(0, 59),
18+
)
19+
1220

1321
@pytest.fixture(scope="session")
1422
def shownotes_text():
@@ -19,6 +27,7 @@ def shownotes_text():
1927
This is some text for the newsletter.
2028
"""
2129

30+
2231
@pytest.fixture(scope="session")
2332
def newsletter_body():
2433
return {
@@ -47,4 +56,4 @@ def issue_text():
4756
Aliquip eiusmod minim excepteur officia **tempor** est incididunt adipisicing elit. Aliqua tempor incididunt magna occaecat esse nulla nostrud. Irure incididunt nulla id eu et. Occaecat quis sit laborum labore nisi minim esse ex ea.
4857
4958
Laboris anim pariatur nisi mollit. Qui nostrud id ipsum quis mollit aliqua est amet tempor nulla. Aute pariatur ullamco qui consequat anim ad nisi ex sit. Quis officia esse incididunt tempor aliqua quis qui est amet. Nisi nostrud sit ea anim voluptate. Est amet mollit consectetur sit et aliquip pariatur nisi enim. Ex sit enim do culpa consectetur irure est duis minim magna do eiusmod est.
50-
"""
59+
"""

automation/tests/test_issues.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
import pytest
2-
from issues import parse_issue_markdown, get_content_issues
32
from engine import engine
3+
from issues import get_content_issues, parse_issue_markdown
4+
45

56
def test_issues_markdown_parsing(issue_text):
67
"""Test the issue text is parsed into segments"""
7-
issue = parse_issue_markdown(issue_text)
8+
issue = parse_issue_markdown(issue_text)
89
assert issue["Issue Name"] == ["Test Issue"]
910
assert "Skipped Section" not in issue
1011
assert len(issue["TextArea Content"]) == 2
1112

13+
1214
def test_malformed_newsletter_issue_raises_issue():
1315
bad_issue = """### Issue Name
1416
There's no issues in here
1517
"""
1618
with pytest.raises(ValueError):
17-
get_content_issues(bad_issue, 'Issue')
19+
get_content_issues(bad_issue, "Issue")
20+
1821

1922
def test_valid_issue_returns_issue_list(issue_text):
20-
assert list(get_content_issues(issue_text, 'Issues')) == ["1","2","3","4"]
23+
assert list(get_content_issues(issue_text, "Issues")) == ["1", "2", "3", "4"]

automation/tests/test_newsletter.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
1-
from tkinter import W
2-
import pytest
3-
import httpx
41
import datetime
5-
import pathlib
62
import json
7-
import engine
3+
import pathlib
4+
from tkinter import W
85

9-
from newsletter import (
10-
get_publish_time,
11-
schedule_email_from_post,
12-
get_show_file,
13-
build_email_from_content,
14-
)
6+
import engine
7+
import httpx
8+
import pytest
9+
from newsletter import (build_email_from_content, get_publish_time,
10+
get_show_file, schedule_email_from_post)
1511

1612

1713
def test_shownotes_date_creation(date, time):
1814
"""Given a date and time, return the publish time for the email in datetime format"""
1915
assert get_publish_time(date, time) == datetime.datetime.combine(date, time)
20-
16+
2117

2218
def test_shownotes_file(date, time, tmp_path):
2319
"""Given the date, time, and temporary_path return the filepath"""
2420
publish_date = datetime.datetime.combine(date, time)
25-
assert get_show_file('fake_directory', publish_date) == pathlib.Path('fake_directory') / pathlib.Path(publish_date.strftime("%Y-%m-%d") + ".md")
21+
assert get_show_file("fake_directory", publish_date) == pathlib.Path(
22+
"fake_directory"
23+
) / pathlib.Path(publish_date.strftime("%Y-%m-%d") + ".md")
2624

2725

2826
def test_shownotes_content(shownotes_text, newsletter_body, tmp_path):
2927
"""Given the shownotes_text, return the body of the email"""
30-
filepath = tmp_path / pathlib.Path('test_path.md')
28+
filepath = tmp_path / pathlib.Path("test_path.md")
3129
filepath.write_text(shownotes_text)
3230
assert build_email_from_content(filepath) == newsletter_body
3331

3432

3533
def test_shownotes_request_from_file(
36-
httpx_mock,
34+
httpx_mock,
3735
newsletter_body,
3836
date,
3937
time,
@@ -44,9 +42,9 @@ def test_shownotes_request_from_file(
4442

4543
with httpx.Client() as _:
4644
request = schedule_email_from_post(newsletter_body, publish_date=publish_date)
47-
content = bytes.decode(httpx_mock.get_requests()[0]._content, 'utf-8')
45+
content = bytes.decode(httpx_mock.get_requests()[0]._content, "utf-8")
4846
assert json.loads(content) == newsletter_body
4947

5048

5149
def test_newsletter_template_exists():
52-
assert 'newsletter.md' in engine.engine.list_templates()
50+
assert "newsletter.md" in engine.engine.list_templates()

requirements.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
black
12
httpx
3+
isort
24
jinja2
3-
render_engine
45
markdown_it_py
56
pip-tools
67
pre-commit
78
pytest
89
pytest-cov
910
pytest-httpx
10-
black
11-
isort
11+
render_engine

site/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from render_engine.site import Site
21
from render_engine.blog import Blog
32
from render_engine.page import Page
3+
from render_engine.site import Site
44

55

66
class Site(Site):
@@ -10,17 +10,18 @@ class Site(Site):
1010
"SITE_URL": "https://pythoncommunitynews.com",
1111
}
1212

13-
if __name__ == '__main__':
13+
14+
if __name__ == "__main__":
1415
site = Site(static="static")
15-
16+
1617
@site.render_page
1718
class index(Page):
18-
template = 'index.html'
19+
template = "index.html"
1920

2021
@site.render_collection
2122
class archive(Blog):
2223
has_archive = True
23-
output_path = './'
24-
content_path = './app/content'
25-
template = 'new_post.html'
26-
archive_template: str = 'archive.html'
24+
output_path = "./"
25+
content_path = "./app/content"
26+
template = "new_post.html"
27+
archive_template: str = "archive.html"

0 commit comments

Comments
 (0)