Skip to content

Commit

Permalink
tests: make rss tests less brittle
Browse files Browse the repository at this point in the history
chore: update dependencies

style: fix lint errors
  • Loading branch information
lyz-code committed Jan 12, 2024
1 parent 796e253 commit d9f6cf7
Show file tree
Hide file tree
Showing 8 changed files with 876 additions and 486 deletions.
1,222 changes: 826 additions & 396 deletions pdm.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ authors = [
{name = "Lyz", email = "[email protected]"},
]
license = {text = "GPL-3.0-only"}
requires-python = ">=3.8"
requires-python = ">=3.8.1"
dependencies = [
"beautifulsoup4>=4.10.0",
"mkdocs>=1.2.3",
Expand Down Expand Up @@ -77,7 +77,7 @@ source-includes = ["tests/"]
source = "file"
path = "src/mkdocs_newsletter/version.py"

[tool.pdm.overrides]
[tool.pdm.resolution.overrides]
# To be removed once https://github.com/flakeheaven/flakeheaven/issues/132 is solved
"importlib-metadata" = ">=3.10"

Expand Down
6 changes: 2 additions & 4 deletions src/mkdocs_newsletter/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

def version_info() -> str:
"""Display the version of the program, python and the platform."""
return dedent(
f"""\
return dedent(f"""\
------------------------------------------------------------------
mkdocs_newsletter: {__version__}
Python: {sys.version.split(" ", maxsplit=1)[0]}
Platform: {platform.platform()}
------------------------------------------------------------------"""
)
------------------------------------------------------------------""")
12 changes: 4 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ def full_repo_(repo: Repo) -> Repo:
commit_date = datetime.datetime(2021, 2, 5, 12, tzinfo=tz.tzlocal())
index.add(["docs/devops/helm/helm.md", "docs/devops/devops.md"])
index.commit(
textwrap.dedent(
"""\
textwrap.dedent("""\
feat(helm): introduce Helm the Kubernetes package manager
[Helm](https://helm.sh/) is the package manager for Kubernetes. Through
Expand All @@ -95,8 +94,7 @@ def full_repo_(repo: Repo) -> Repo:
One of the most important goals of the DevOps initiative is to break the
silos between the developers and the sysadmins, that lead to ill feelings
and unproductivity."""
),
and unproductivity."""),
author=author,
committer=committer,
author_date=commit_date,
Expand Down Expand Up @@ -145,12 +143,10 @@ def full_repo_(repo: Repo) -> Repo:
commit_date = datetime.datetime(2021, 3, 2, 12, tzinfo=tz.tzlocal())
index.add(["docs/coding/tdd.md", "docs/coding/python/gitpython.md"])
index.commit(
textwrap.dedent(
"""\
textwrap.dedent("""\
feat(tdd): define test driven development
feat(gitpython): present the python library"""
),
feat(gitpython): present the python library"""),
author=author,
committer=committer,
author_date=commit_date,
Expand Down
28 changes: 12 additions & 16 deletions tests/e2e/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_plugin_creates_daily_rss_feed(full_repo: Repo, config: MkDocsConfig) ->
feed.entries[0].link
== "https://lyz-code.github.io/blue-book/newsletter/2021_03_02/"
)
assert feed.entries[0].description == (
assert (
'<article class="md-content__inner md-typeset">\n\n'
'<h2 id="coding">Coding</h2>\n'
'<h3 id="tdd"><a href="https://lyz-code.github.io/blue-book/coding/tdd/">TDD'
Expand All @@ -93,9 +93,8 @@ def test_plugin_creates_daily_rss_feed(full_repo: Repo, config: MkDocsConfig) ->
"GitPython</a>"
"</h4>\n"
"<ul>\n<li>New: Present the python library.</li>\n"
"</ul>\n<hr />\n\n"
"</article>"
)
"</ul>"
) in feed.entries[0].description
assert parser.parse(feed.entries[0].published) == now
assert feed.entries[0].author == "Lyz"

Expand Down Expand Up @@ -141,7 +140,7 @@ def test_plugin_creates_weekly_rss_feed(full_repo: Repo, config: MkDocsConfig) -
feed.entries[0].link
== "https://lyz-code.github.io/blue-book/newsletter/2021_w09/"
)
assert feed.entries[0].description == (
assert (
'<article class="md-content__inner md-typeset">\n\n'
'<h2 id="coding">Coding</h2>\n'
'<h3 id="tdd"><a href="https://lyz-code.github.io/blue-book/coding/tdd/">TDD'
Expand All @@ -153,9 +152,8 @@ def test_plugin_creates_weekly_rss_feed(full_repo: Repo, config: MkDocsConfig) -
"GitPython</a>"
"</h4>\n"
"<ul>\n<li>New: Present the python library.</li>\n"
"</ul>\n<hr />\n\n"
"</article>"
)
"</ul>"
) in feed.entries[0].description
assert parser.parse(feed.entries[0].published) == now
assert feed.entries[0].author == "Lyz"

Expand Down Expand Up @@ -201,7 +199,7 @@ def test_plugin_creates_monthly_rss_feed(full_repo: Repo, config: MkDocsConfig)
feed.entries[0].link
== "https://lyz-code.github.io/blue-book/newsletter/2021_03/"
)
assert feed.entries[0].description == (
assert (
'<article class="md-content__inner md-typeset">\n\n'
'<h2 id="coding">Coding</h2>\n'
'<h3 id="tdd"><a href="https://lyz-code.github.io/blue-book/coding/tdd/">TDD'
Expand All @@ -213,9 +211,8 @@ def test_plugin_creates_monthly_rss_feed(full_repo: Repo, config: MkDocsConfig)
"GitPython</a>"
"</h4>\n"
"<ul>\n<li>New: Present the python library.</li>\n"
"</ul>\n<hr />\n\n"
"</article>"
)
"</ul>"
) in feed.entries[0].description
assert parser.parse(feed.entries[0].published) == now
assert feed.entries[0].author == "Lyz"

Expand Down Expand Up @@ -260,7 +257,7 @@ def test_plugin_creates_yearly_rss_feed(full_repo: Repo, config: MkDocsConfig) -
assert (
feed.entries[0].link == "https://lyz-code.github.io/blue-book/newsletter/2021/"
)
assert feed.entries[0].description == (
assert (
'<article class="md-content__inner md-typeset">\n\n'
'<h2 id="devops"><a href="https://lyz-code.github.io/blue-book/devops/devops/">'
"DevOps</a></h2>\n"
Expand Down Expand Up @@ -291,9 +288,8 @@ def test_plugin_creates_yearly_rss_feed(full_repo: Repo, config: MkDocsConfig) -
'<h2 id="other">Other</h2>\n'
"<ul>\n<li>New: Add funny emojis.</li>\n"
"<li>New: Add ash, birch and beech information.</li>\n"
"</ul>\n<hr />\n\n"
"</article>"
)
"</ul>"
) in feed.entries[0].description
assert parser.parse(feed.entries[0].published) == now
assert feed.entries[0].author == "Lyz"

Expand Down
24 changes: 8 additions & 16 deletions tests/unit/services/test_last_newsletters.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,10 @@ def test_create_newsletter_creates_daily_article(repo: Repo) -> None:
category_order=0,
file_="index.md",
)
file_content = dedent(
"""\
file_content = dedent("""\
# [Introduction](index.md)
* New: Create the introduction page"""
)
* New: Create the introduction page""")
changes_to_publish = DigitalGardenChanges(daily=[change])

result = create_newsletters(changes_to_publish, repo)
Expand Down Expand Up @@ -554,12 +552,10 @@ def test_create_newsletter_creates_weekly_articles(repo: Repo) -> None:
category_order=0,
file_="index.md",
)
file_content = dedent(
"""\
file_content = dedent("""\
# [Introduction](index.md)
* New: Create the introduction page"""
)
* New: Create the introduction page""")
changes_to_publish = DigitalGardenChanges(weekly=[change])

result = create_newsletters(changes_to_publish, repo)
Expand Down Expand Up @@ -588,12 +584,10 @@ def test_create_newsletter_creates_monthly_articles(repo: Repo) -> None:
category_order=0,
file_="index.md",
)
file_content = dedent(
"""\
file_content = dedent("""\
# [Introduction](index.md)
* New: Create the introduction page"""
)
* New: Create the introduction page""")
changes_to_publish = DigitalGardenChanges(monthly=[change])

result = create_newsletters(changes_to_publish, repo)
Expand Down Expand Up @@ -622,12 +616,10 @@ def test_create_newsletter_creates_yearly_articles(repo: Repo) -> None:
category_order=0,
file_="index.md",
)
file_content = dedent(
"""\
file_content = dedent("""\
# [Introduction](index.md)
* New: Create the introduction page"""
)
* New: Create the introduction page""")
changes_to_publish = DigitalGardenChanges(yearly=[change])

result = create_newsletters(changes_to_publish, repo)
Expand Down
18 changes: 6 additions & 12 deletions tests/unit/services/test_semantic_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ def test_changes_extracts_commits_with_multiple_changes(repo: Repo) -> None:
commit_date = datetime.datetime(2021, 2, 5, tzinfo=tz.tzlocal())
repo.index.add(["docs/devops/helm/helm.md", "docs/devops/devops.md"])
repo.index.commit(
textwrap.dedent(
"""\
textwrap.dedent("""\
feat(helm): introduce Helm the Kubernetes package manager
[Helm](https://helm.sh/) is the package manager for Kubernetes.
Expand All @@ -100,8 +99,7 @@ def test_changes_extracts_commits_with_multiple_changes(repo: Repo) -> None:
One of the most important goals of the DevOps initiative is to break
the silos between the developers and the sysadmins, that lead to ill
feelings and unproductivity."""
),
feelings and unproductivity."""),
author=author,
committer=committer,
author_date=commit_date,
Expand All @@ -111,29 +109,25 @@ def test_changes_extracts_commits_with_multiple_changes(repo: Repo) -> None:
Change(
date=commit_date,
summary="Introduce Helm the Kubernetes package manager.",
message=dedent(
"""\
message=dedent("""\
[Helm](https://helm.sh/) is the package manager for Kubernetes.
Through charts it helps you define, install and upgrade even the most
complex Kubernetes applications."""
),
complex Kubernetes applications."""),
type_="feature",
scope="helm",
),
Change(
date=commit_date,
summary="Define DevOps.",
message=dedent(
"""\
message=dedent("""\
[DevOps](https://en.wikipedia.org/wiki/DevOps) is a set of practices
that combines software development (Dev) and information-technology
operations (Ops) which aims to shorten the systems development life
cycle and provide continuous delivery with high software quality.
One of the most important goals of the DevOps initiative is to break
the silos between the developers and the sysadmins, that lead to ill
feelings and unproductivity."""
),
feelings and unproductivity."""),
type_="feature",
scope="devops",
),
Expand Down
Loading

0 comments on commit d9f6cf7

Please sign in to comment.