Skip to content

Use underscores instead of spaces in paths #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions blurb_it/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@


async def get_misc_news_filename(issue_number, section, body):
if " " in 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"
Expand Down
6 changes: 3 additions & 3 deletions templates/add_blurb.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ <h3>📜🤖 Blurb it again?</h3>
<select id="section" name="section" class="form-control form-inline" required>
<option></option>
<option>Security</option>
<option>Core and Builtins</option>
<option value="Core_and_Builtins">Core and Builtins</option>
<option>Library</option>
<option>Documentation</option>
<option>Tests</option>
<option>Build</option>
<option>Windows</option>
<option>macOS</option>
<option>IDLE</option>
<option>Tools-Demos</option>
<option>C API</option>
<option value="Tools-Demos">Tools and Demos</option>
<option value="C_API">C API</option>
</select>
</div>
</div>
Expand Down
22 changes: 22 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ 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 underscores not spaces in section name: Core and Builtins",
):
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()

Expand Down