Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Commit

Permalink
fix(issue-updated): return early if no youtube url found (#4250)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher authored May 30, 2024
1 parent 306fafb commit 28bc536
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ def process_issue_update(database_url: Optional[str] = None, youtube_url: Option
if not youtube_url:
youtube_url = check_youtube(data=submission)

if not youtube_url:
exception_writer(error=Exception('Error processing YouTube url'), name='youtube', end_program=False)
return False

# regex map
regex_map = {
'game': r'https://www\.igdb\.com/games/(.+)/*.*',
Expand Down
14 changes: 14 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,20 @@ def submission_empty_value():
os.remove(submission_file)


@pytest.fixture(scope='function')
def submission_invalid_youtube():
submission_data = dict(
database_url='https://www.igdb.com/games/goldeneye-007',
youtube_theme_url='https://www.youtube.com/watch?v=invalid',
)

submission_file = create_submission_file(data=submission_data)

yield submission_data

os.remove(submission_file)


@pytest.fixture(scope='function')
def exceptions_file():
exceptions_file = os.path.join(os.getcwd(), 'exceptions.md')
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/test_issue_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ def test_process_issue_update(db_url, db_type, issue_update_args, igdb_auth, tmd
assert data == db_type


def test_process_issue_update_invalid_youtube(issue_update_args, tmdb_auth, submission_invalid_youtube):
"""Tests if the provided YouTube url is invalid and raises an exception."""
data = updater.process_issue_update()
assert not data
assert data is False


@pytest.mark.parametrize('url_suffix', [
'',
'&list=PLE0hg-LdSfycrpTtMImPSqFLle4yYNzWD',
Expand Down

0 comments on commit 28bc536

Please sign in to comment.