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