-
Notifications
You must be signed in to change notification settings - Fork 0
🧪 [Test is_valid_video_id edge cases] #61
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -105,6 +105,38 @@ def test_non_string(self): | |||||
| """Test with non-string value""" | ||||||
| assert is_valid_video_id(12345678901) is False | ||||||
|
|
||||||
| def test_exact_length_with_whitespace(self): | ||||||
| """Test 11-character string with whitespace""" | ||||||
| assert is_valid_video_id("auJzb1D fag") is False | ||||||
| assert is_valid_video_id("auJzb\tD-fag") is False | ||||||
| assert is_valid_video_id("auJzb\nD-fag") is False | ||||||
|
|
||||||
| def test_exact_length_with_special_chars(self): | ||||||
| """Test 11-character string with invalid special characters""" | ||||||
| assert is_valid_video_id("auJzb1D*fag") is False | ||||||
| assert is_valid_video_id("auJzb1D@fag") is False | ||||||
| assert is_valid_video_id("auJzb1D.fag") is False | ||||||
| assert is_valid_video_id("auJzb1D/fag") is False | ||||||
|
|
||||||
| def test_boundary_lengths(self): | ||||||
| """Test lengths exactly at the boundaries""" | ||||||
| assert is_valid_video_id("1234567890") is False # 10 chars | ||||||
| assert is_valid_video_id("123456789012") is False # 12 chars | ||||||
| assert is_valid_video_id("12345678901") is True # 11 chars (all numbers) | ||||||
| assert is_valid_video_id("-----------") is True # 11 chars (all hyphens) | ||||||
| assert is_valid_video_id("___________") is True # 11 chars (all underscores) | ||||||
|
|
||||||
| def test_leading_trailing_whitespace(self): | ||||||
| """Test valid IDs with leading or trailing whitespace""" | ||||||
| assert is_valid_video_id(" auJzb1D-fag") is False | ||||||
| assert is_valid_video_id("auJzb1D-fag ") is False | ||||||
| assert is_valid_video_id("\tauJzb1D-fag\n") is False | ||||||
|
|
||||||
| def test_url_instead_of_id(self): | ||||||
| """Test full URLs (should fail as it expects only the ID)""" | ||||||
| assert is_valid_video_id("https://www.youtube.com/watch?v=auJzb1D-fag") is False | ||||||
| assert is_valid_video_id("youtube.com/watch?v=auJzb1D") is False | ||||||
|
||||||
| assert is_valid_video_id("youtube.com/watch?v=auJzb1D") is False | |
| assert is_valid_video_id("youtube.com/watch?v=12345678901") is False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While these tests are great for coverage, they can be consolidated using
pytest.mark.parametrize. This will make the test suite more concise and easier to maintain.This refactoring groups all new invalid test cases into one parameterized test and all new valid cases into another. It also adds type hints to the test function parameters, adhering to the repository's style guide on strict type hinting.
References