Skip to content

Commit 94d6df7

Browse files
test: add comprehensive tests for Discord username underscore patterns (#150) (#235)
* test: add comprehensive tests for Discord username underscore patterns (#150) - Add test_discord_username_ending_with_underscore to verify issue #150 is resolved - Add test_discord_username_underscore_variations with parametrized test cases - Test usernames ending with underscores, starting with underscores, and mixed patterns - Confirms that Discord username validation already correctly accepts underscores - All tests pass, indicating the reported issue has been resolved Related to: #150 * style: apply Black formatting to test_models.py - Fix code formatting to comply with project linting standards - No functional changes, only formatting improvements - All tests continue to pass * Remove redundant Discord username test per code review - Remove test_discord_username_ending_with_underscore as it duplicates coverage - The parametrized test_discord_username_underscore_variations already covers 'username_' case Related to: #150
1 parent ac992e2 commit 94d6df7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/volunteer/test_models.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,27 @@ def test_discord_username_length_validation(self, portal_user):
316316
excinfo.value
317317
)
318318

319+
@pytest.mark.parametrize(
320+
"username,description",
321+
[
322+
("username_", "Username ending with underscore"),
323+
("_username", "Username starting with underscore"),
324+
("user_name_", "Username with multiple underscores"),
325+
("user.name_", "Username with period and ending underscore"),
326+
("valid_user123_", "Username with numbers and ending underscore"),
327+
],
328+
)
329+
def test_discord_username_underscore_variations(
330+
self, portal_user, username, description
331+
):
332+
"""Test various underscore patterns in Discord usernames (issue #150)."""
333+
profile = VolunteerProfile(
334+
user=portal_user, region=Region.NORTH_AMERICA, discord_username=username
335+
)
336+
337+
# This should not raise ValidationError
338+
profile.full_clean()
339+
319340
def test_email_is_sent_after_saved(self, portal_user):
320341
# set up an admin account to receive internal notification email
321342
admin_role = Role.objects.create(

0 commit comments

Comments
 (0)