Skip to content
Open
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 .github/workflows/auto-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Auto Label
on:
pull_request:
types: [opened, reopened, synchronized]
permissions:
pull-requests: write
jobs:
label:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
types: [opened, reopened, synchronize, edited]
permissions:
issues: write
pull-requests: write
jobs:
validate:
runs-on: ubuntu-latest
Expand All @@ -17,7 +18,7 @@ jobs:
if (pr.title.length < 10) {
issues.push('❌ PR title too short (minimum 10 characters)');
}
if (!/^(feat|fix|docs|style|refactor|test|chore|perf|ci|build|revert)(\(.+\))?:/.test(pr.title)) {
if (!/^(?:[\p{Emoji}\u200d\s\W]+)?(feat|fix|docs|style|refactor|test|chore|perf|ci|build|revert)(\(.+\))?[:\]\s]/iu.test(pr.title)) {
issues.push('⚠️ PR title should follow conventional commits format');
}

Expand Down
32 changes: 32 additions & 0 deletions tests/testing/test_video_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +108 to +138
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

    @pytest.mark.parametrize(
        "invalid_id",
        [
            # 11 chars with whitespace
            "auJzb1D fag",
            "auJzb\tD-fag",
            "auJzb\nD-fag",
            # 11 chars with invalid special characters
            "auJzb1D*fag",
            "auJzb1D@fag",
            "auJzb1D.fag",
            "auJzb1D/fag",
            # Boundary lengths
            "1234567890",  # 10 chars
            "123456789012",  # 12 chars
            # Leading/trailing whitespace
            " auJzb1D-fag",
            "auJzb1D-fag ",
            "\tauJzb1D-fag\n",
            # Full URLs
            "https://www.youtube.com/watch?v=auJzb1D-fag",
            "youtube.com/watch?v=auJzb1D",
        ],
    )
    def test_various_invalid_ids(self, invalid_id: str) -> None:
        """Test various invalid video ID formats that should fail validation."""
        assert is_valid_video_id(invalid_id) is False

    @pytest.mark.parametrize(
        "valid_id",
        [
            "12345678901",  # 11 chars (all numbers)
            "-----------",  # 11 chars (all hyphens)
            "___________",  # 11 chars (all underscores)
        ],
    )
    def test_various_valid_ids(self, valid_id: str) -> None:
        """Test various valid 11-character video IDs."""
        assert is_valid_video_id(valid_id) is True
References
  1. All functions must have strict type hinting. The suggested change adds type hints to the parameters of the new test functions. (link)

Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In test_url_instead_of_id, the second example ("youtube.com/watch?v=auJzb1D") fails both because it’s a URL string and because the embedded ID is not 11 characters. That makes the test less specific to the “URL instead of ID” behavior. Consider using an 11-character ID in that URL (or adding a separate case) so the failure is attributable solely to the input being a URL rather than a bare ID.

Suggested change
assert is_valid_video_id("youtube.com/watch?v=auJzb1D") is False
assert is_valid_video_id("youtube.com/watch?v=12345678901") is False

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert is_valid_video_id("youtube.com/watch?v=auJzb1D") is False
assert is_valid_video_id("youtube.com/watch?v=12345678901") is False

Test case uses 7-character ID instead of 11-character ID, making test intent unclear

Fix on Vercel



class TestNormalizeVideoUrl:
"""Tests for normalize_video_url function"""
Expand Down
Loading