fixes for file naming
formatting_check / formatting_check (push) Failing after 6s
Python Test / test (.sh, ubuntu-latest, 3.9) (push) Failing after 16s
Python Test / test (.ps1, windows-latest, 3.9) (push) Has been cancelled
Python Test / test (.sh, macos-latest, 3.9) (push) Has been cancelled

This commit is contained in:
2026-07-14 21:11:24 +12:00
parent 8f8e2c744d
commit f3dc8e46fd
16 changed files with 236 additions and 117 deletions
+33
View File
@@ -519,3 +519,36 @@ def test_name_submission(
results = test_formatter.format_resource_paths(test_resources, Path())
results = set([r[0].name for r in results])
assert results == expected_names
@pytest.mark.parametrize(
("input_string", "expected"),
(
("Test 💕 emoji", "Test emoji"),
("Normal text", "Normal text"),
("Kirsty-Blue's post", "Kirsty-Blue's post"),
("Hello 😀 world 🌍", "Hello world "),
("No emoji here", "No emoji here"),
),
)
def test_strip_unicode_chars(input_string: str, expected: str):
result = FileNameFormatter._strip_unicode_chars(input_string)
assert result == expected
def test_unicode_stripping_enabled(submission: MagicMock):
"""Test that Unicode stripping is applied when enabled"""
submission.title = 'Test 💕 emoji'
formatter = FileNameFormatter("{TITLE}", "", "", strip_unicode=True)
result = formatter._format_name(submission, "{TITLE}")
assert "💕" not in result
assert result == "Test emoji"
def test_unicode_stripping_disabled(submission: MagicMock):
"""Test that Unicode stripping is not applied when disabled"""
submission.title = 'Test 💕 emoji'
formatter = FileNameFormatter("{TITLE}", "", "", strip_unicode=False)
result = formatter._format_name(submission, "{TITLE}")
assert "💕" in result
assert result == "Test 💕 emoji"