From 23fcb058c49fc16dab7a9152a52d0003e2a5689c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 28 Mar 2023 23:51:34 +0300 Subject: [PATCH 1/6] Use dashes instead of spaces in paths --- templates/add_blurb.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/add_blurb.html b/templates/add_blurb.html index 87f1ae3..71a124c 100644 --- a/templates/add_blurb.html +++ b/templates/add_blurb.html @@ -38,7 +38,7 @@

πŸ“œπŸ€– Blurb it again?

From f0f2b4f0aa8d0e17aaf67404f47093f386615292 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 3 Apr 2023 18:19:06 +0300 Subject: [PATCH 2/6] Test get_misc_news_filename with hyphens and spaces, and reject spaces --- blurb_it/util.py | 2 ++ tests/test_util.py | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/blurb_it/util.py b/blurb_it/util.py index 4cc536a..55165f8 100644 --- a/blurb_it/util.py +++ b/blurb_it/util.py @@ -9,6 +9,8 @@ async def get_misc_news_filename(issue_number, section, body): + if " " in section: + raise ValueError(f"Use hyphens not spaces in section name: {section}") date = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) nonce = await nonceify(body) path = f"Misc/NEWS.d/next/{section}/{date}.gh-issue-{issue_number}.{nonce}.rst" diff --git a/tests/test_util.py b/tests/test_util.py index 8de474e..45c8527 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -57,6 +57,27 @@ async def test_get_misc_news_filename(): assert path.endswith(".gh-issue-123.Ps4kgC.rst") +async def test_get_misc_news_filename_sections_with_dashes(): + path = await util.get_misc_news_filename( + issue_number=123, + section="Core-and-Builtins", + body="Lorem ipsum dolor amet flannel squid normcore tbh raclette enim", + ) + + assert path.startswith("Misc/NEWS.d/next/Core-and-Builtins/") + + +async def test_get_misc_news_filename_sections_with_space(): + with pytest.raises( + ValueError, match="Use hyphens not spaces in section name: Core and Builtins" + ): + path = await util.get_misc_news_filename( + issue_number=123, + section="Core and Builtins", + body="Lorem ipsum dolor amet flannel squid normcore tbh raclette enim", + ) + + async def test_has_session(): request = mock_request_session() From c75763e92afbfac952b61c73b99c5616e45584de Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 24 Jul 2023 08:49:25 +0300 Subject: [PATCH 3/6] Use underscores instead of dashes for spaces --- blurb_it/util.py | 2 +- templates/add_blurb.html | 4 ++-- tests/test_util.py | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/blurb_it/util.py b/blurb_it/util.py index 55165f8..5d84df9 100644 --- a/blurb_it/util.py +++ b/blurb_it/util.py @@ -10,7 +10,7 @@ async def get_misc_news_filename(issue_number, section, body): if " " in section: - raise ValueError(f"Use hyphens not spaces in section name: {section}") + raise ValueError(f"Use underscores not spaces in section name: {section}") date = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) nonce = await nonceify(body) path = f"Misc/NEWS.d/next/{section}/{date}.gh-issue-{issue_number}.{nonce}.rst" diff --git a/templates/add_blurb.html b/templates/add_blurb.html index 71a124c..9babb94 100644 --- a/templates/add_blurb.html +++ b/templates/add_blurb.html @@ -38,7 +38,7 @@

πŸ“œπŸ€– Blurb it again?

diff --git a/tests/test_util.py b/tests/test_util.py index 45c8527..89285f7 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -60,7 +60,7 @@ async def test_get_misc_news_filename(): async def test_get_misc_news_filename_sections_with_dashes(): path = await util.get_misc_news_filename( issue_number=123, - section="Core-and-Builtins", + section="Core_and_Builtins", body="Lorem ipsum dolor amet flannel squid normcore tbh raclette enim", ) @@ -69,9 +69,10 @@ async def test_get_misc_news_filename_sections_with_dashes(): async def test_get_misc_news_filename_sections_with_space(): with pytest.raises( - ValueError, match="Use hyphens not spaces in section name: Core and Builtins" + ValueError, + match="Use underscores not spaces in section name: Core and Builtins", ): - path = await util.get_misc_news_filename( + await util.get_misc_news_filename( issue_number=123, section="Core and Builtins", body="Lorem ipsum dolor amet flannel squid normcore tbh raclette enim", From e51ed081861784d3c46b288400446e31973ea74d Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Sun, 7 Jul 2024 21:53:43 +0300 Subject: [PATCH 4/6] blurb uses underscores not hyphens --- tests/test_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_util.py b/tests/test_util.py index 89285f7..00dcf2a 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -64,7 +64,7 @@ async def test_get_misc_news_filename_sections_with_dashes(): body="Lorem ipsum dolor amet flannel squid normcore tbh raclette enim", ) - assert path.startswith("Misc/NEWS.d/next/Core-and-Builtins/") + assert path.startswith("Misc/NEWS.d/next/Core_and_Builtins/") async def test_get_misc_news_filename_sections_with_space(): From a64d1910c32480c133bae952f9ce7b9b80378a5c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 8 Jul 2024 04:19:26 -0600 Subject: [PATCH 5/6] Show spaces but use underscores MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Γ‰ric --- templates/add_blurb.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/add_blurb.html b/templates/add_blurb.html index 9babb94..0199d0b 100644 --- a/templates/add_blurb.html +++ b/templates/add_blurb.html @@ -38,7 +38,7 @@

πŸ“œπŸ€– Blurb it again?

From a68b12412d1b7cb5b8396b6012917d7815a1e94f Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 8 Jul 2024 04:20:06 -0600 Subject: [PATCH 6/6] Show spaces but use hyphen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Γ‰ric --- templates/add_blurb.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/add_blurb.html b/templates/add_blurb.html index 0199d0b..25fe9d0 100644 --- a/templates/add_blurb.html +++ b/templates/add_blurb.html @@ -46,7 +46,7 @@

πŸ“œπŸ€– Blurb it again?

- +