@@ -500,16 +500,17 @@ def test_write_item_files_writes_primary_and_imdb_copy(tmp_path, monkeypatch):
500500
501501
502502def test_load_issue_submission_values_uses_supplied_values (monkeypatch ):
503- """Test fully supplied issue-update values bypass submission processing ."""
503+ """Test fully supplied issue-update values bypass submission loading but still validate YouTube ."""
504504 monkeypatch .setattr (
505505 updater ,
506506 'process_submission' ,
507507 lambda : pytest .fail ('submission file should not be read' ),
508508 )
509+ monkeypatch .setattr (updater , 'check_youtube' , lambda data : f"canonical-{ data ['youtube_theme_url' ]} " )
509510
510511 assert updater ._load_issue_submission_values (database_url = 'database-url' , youtube_url = 'youtube-url' ) == (
511512 'database-url' ,
512- 'youtube-url' ,
513+ 'canonical- youtube-url' ,
513514 {},
514515 )
515516
@@ -564,6 +565,7 @@ def test_process_issue_update(
564565 issue_update_args ,
565566 mock_igdb_api ,
566567 mock_tmdb_api ,
568+ mock_youtube_api ,
567569 youtube_url ,
568570 tmp_path ,
569571 monkeypatch ,
@@ -1273,7 +1275,7 @@ def test_update_contributor_info_increments_existing_edit(tmp_path, monkeypatch)
12731275 }
12741276
12751277
1276- def test_process_issue_update_reports_unsupported_database_url (tmp_path , monkeypatch , youtube_url ):
1278+ def test_process_issue_update_reports_unsupported_database_url (tmp_path , monkeypatch , mock_youtube_api , youtube_url ):
12771279 """Test that unsupported database URLs report every regex miss."""
12781280 monkeypatch .chdir (tmp_path )
12791281
@@ -1284,10 +1286,12 @@ def test_process_issue_update_reports_unsupported_database_url(tmp_path, monkeyp
12841286
12851287 assert result is False
12861288 exceptions = (tmp_path / 'exceptions.md' ).read_text ()
1289+ comment = (tmp_path / 'comment.md' ).read_text (encoding = 'utf-8' )
12871290 assert exceptions .count ('Exception Occurred' ) == 6
1291+ assert comment .count ('Exception Occurred' ) == 6
12881292
12891293
1290- def test_process_issue_update_writes_author_badges_first (tmp_path , monkeypatch , youtube_url ):
1294+ def test_process_issue_update_writes_author_badges_first (tmp_path , monkeypatch , mock_youtube_api , youtube_url ):
12911295 """Test issue update comments start with the author badges."""
12921296 monkeypatch .chdir (tmp_path )
12931297 monkeypatch .setenv ('GITHUB_REPOSITORY' , 'LizardByte/ThemerrDB' )
@@ -1315,6 +1319,50 @@ def test_process_issue_update_writes_author_badges_first(tmp_path, monkeypatch,
13151319 assert 'Exception Occurred' in comment
13161320
13171321
1322+ def test_process_issue_update_reports_invalid_supplied_youtube_url (tmp_path , monkeypatch ):
1323+ """Test supplied invalid YouTube URLs are written to the issue comment."""
1324+ monkeypatch .chdir (tmp_path )
1325+
1326+ result = updater .process_issue_update (
1327+ database_url = 'https://www.igdb.com/games/goldeneye-007' ,
1328+ youtube_url = 'https://www.youtube.com/watch?v=invalid' ,
1329+ )
1330+
1331+ comment = (tmp_path / 'comment.md' ).read_text (encoding = 'utf-8' )
1332+ assert result is False
1333+ assert 'Could not extract video ID from URL' in comment
1334+
1335+
1336+ def test_process_issue_update_reports_tmdb_not_found_in_comment (
1337+ tmp_path ,
1338+ monkeypatch ,
1339+ issue_update_args ,
1340+ mock_youtube_api ,
1341+ youtube_url ,
1342+ ):
1343+ """Test issue-update TMDB 404 responses are written to the issue comment."""
1344+ monkeypatch .chdir (tmp_path )
1345+ monkeypatch .setenv ('TMDB_API_KEY_V3' , 'test-key' )
1346+ monkeypatch .setitem (
1347+ updater .databases ['movie' ],
1348+ 'path' ,
1349+ str (tmp_path / 'database' / 'movies' / 'themoviedb' ),
1350+ )
1351+
1352+ response = MagicMock ()
1353+ response .status_code = 404
1354+ monkeypatch .setattr (updater , 'requests_loop' , lambda ** kwargs : response )
1355+
1356+ result = updater .process_issue_update (
1357+ database_url = 'https://www.themoviedb.org/movie/42903-missing' ,
1358+ youtube_url = youtube_url ,
1359+ )
1360+
1361+ comment = (tmp_path / 'comment.md' ).read_text (encoding = 'utf-8' )
1362+ assert result is False
1363+ assert 'Error processing TMDB url: movie id 42903 not found or unavailable' in comment
1364+
1365+
13181366def mock_youtube_build (monkeypatch , response = None , exception = None ):
13191367 """Patch googleapiclient discovery build with a fake YouTube service."""
13201368 class Request :
0 commit comments