Input validation work and error handling

This commit is contained in:
Bradley committed 2026-11-13 22:18:45 -05:00
1 parent 4e2520ee76
commit 554b7cc82c
20 files changed
+627 -96

No files matched your search

+13
View File
@@ -226,6 +226,19 @@ class YouTubeDownloadJobTest(unittest.TestCase):
"SELECT COUNT(*) FROM youtube_download_job WHERE youtube_download_job_status = 'failed'"
).fetchone(), (4,))
def test_worker_rejects_a_legacy_catalog_name_collision(self):
self.insert_job()
self.db.execute("UPDATE youtube_download_job SET youtube_download_job_media_name = 'VIDEO'")
self.db.execute("INSERT INTO media (media_name, media_uri) VALUES ('Video', 'existing')")
self.db.commit()
with patch('youtube_downloader.download_video', return_value=(self.workdir / 'video.mp4', 'Title')):
with self.assertLogs('youtube_downloader', level='ERROR'):
self.assertFalse(process_next_job(self.db, self.workdir, max_retries=0))
self.assertEqual(self.db.execute('SELECT media_name, media_uri FROM media').fetchall(), [('Video', 'existing')])
self.assertEqual(self.db.execute(
'SELECT youtube_download_job_status, youtube_download_job_retry_count FROM youtube_download_job'
).fetchone(), ('failed', 1))
def test_claims_oldest_pending_job_only_once(self):
first = self.insert_job()
second = self.insert_job()