import unittest from python_sponsorblock import SponsorBlock, exceptions MAGIC_ID = "dQw4w9WgXcQ" class TestVideoIdParsing(unittest.TestCase): def test_already_parsed_id(self): s = SponsorBlock() self.assertEqual(s._get_video_id(MAGIC_ID), MAGIC_ID) def test_non_existing_id(self): s = SponsorBlock() with self.assertRaises(exceptions.SponsorBlockIdNotFoundError): s._get_video_id("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") s = SponsorBlock(silent=True) self.assertEqual(s._get_video_id("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"), None) def test_youtu_dot_be(self): s = SponsorBlock() self.assertEqual(s._get_video_id("https://youtu.be/" + MAGIC_ID), MAGIC_ID) def test_youtube_dot_com(self): s = SponsorBlock() self.assertEqual(s._get_video_id("https://www.youtube.com/watch?v=" + MAGIC_ID), MAGIC_ID) def test_invidious(self): s = SponsorBlock() self.assertEqual(s._get_video_id("https://invidio.us/watch?v=" + MAGIC_ID), MAGIC_ID) def test_piped(self): s = SponsorBlock() self.assertEqual(s._get_video_id("https://piped.video/watch?v=" + MAGIC_ID), MAGIC_ID) if __name__ == "__main__": unittest.main()