Skip to content

Youtube is Broke #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions tests/test_captions.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'''
Last Updated: 11/30/2018
Last Updated: 12/20/2018

Tests the parameters for the `get_captions` method in the YoutubeDataApi

TO DO
=====
* parser
* LIST OF VALID VIDEO IDS DOES NOT WORK AND I HAVE NO IDEA WHY
NONE!

Functions Tested
================
Expand All @@ -16,6 +15,7 @@ def get_captions(self, video_id, lang_code='en', parser=P.parse_caption_track, *
====
* video_id
* lang_code
* parser

'''
import sys
Expand All @@ -26,16 +26,16 @@ def get_captions(self, video_id, lang_code='en', parser=P.parse_caption_track, *
from collections import OrderedDict

from youtube_api import YoutubeDataApi
from youtube_api import parsers as P

class TestVideo(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.key = os.environ.get('YT_KEY')
cls.yt = YoutubeDataApi(cls.key)
cls.video_id = 'wmxDZeh8W34'
cls.video_id_list = ['wmxDZeh8W34', 'PIXQdfiRZNk','nvEFb_dWJdQ']
cls.fake_vid = '12345'

def __init__():
self.key = os.environ.get('YT_KEY')
self.yt = YoutubeDataApi(self.key)
self.video_id = 'wmxDZeh8W34'
self.video_id_list = ['wmxDZeh8W34', 'PIXQdfiRZNk','nvEFb_dWJdQ']
self.fake_vid = '12345'

#Verified by Megan Brown on 11/30/2018
def test_valid_caption(self):
Expand All @@ -44,12 +44,12 @@ def test_valid_caption(self):
self.assertEqual(type(resp), dict)
self.assertEqual(type(resp['video_id']), str)

'''#Written by Megan Brown on 11/30/2018
#Written by Megan Brown on 11/30/2018
def test_valid_list_of_captions(self):
resp = self.yt.get_captions(self.video_id_list)

self.assertEqual(type(resp), list)
self.assertEqual(type(resp[0]['video_id']), str)'''
self.assertEqual(type(resp[0]['video_id']), str)

#Written by Megan Brown on 11/30/2018
def test_invalid_short_caption(self):
Expand All @@ -63,6 +63,11 @@ def test_list_of_captions_with_invalid_string(self):

with self.assertRaises(Exception):
resp = self.yt.get_captions(error_list)

#Written by Megan Brown on 12/20/2018
def test_caption_parser_w_raw_json(self):
captions = self.yt.get_captions(self.video_id, parser=P.raw_json)
self.assertTrue(isinstance(self.captions, dict))

if __name__ == '__main__':
unittest.main()
17 changes: 10 additions & 7 deletions tests/test_channel_methods.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'''
Last Updated: 11/30/2018
Last Updated: 12/28/2018

Tests the parameters for the channel methods in the YoutubeDataApi

Expand Down Expand Up @@ -69,18 +69,21 @@ def get_featured_channels_gen(self, channel_id, parser=P.parse_featured_channels

class TestVideo(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.key = os.environ.get('YT_KEY')
cls.yt = YoutubeDataApi(cls.key)
cls.channel_id = 'UC3XTzVzaHQEd30rQbuvCtTQ'
cls.channel_title = 'LastWeekTonight'
def __init__():
self.key = os.environ.get('YT_KEY')
self.yt = YoutubeDataApi(self.key)
self.channel_id = 'UC3XTzVzaHQEd30rQbuvCtTQ'
self.channel_title = 'LastWeekTonight'

#written by Megan Brown on 11/30/2018
def test_channel_id(self):
resp = self.yt.get_channel_id_from_user(channel_title)
self.assertEqual(resp, self.channel_id)

def test_get_channel_metadata_channel_id(self):
resp = self.yt.get_channel_metadata(self.channel_id)
self.assertEqual(resp['channel_id'], self.channel_id)
self.assertEqual(resp['channel_title'])

if __name__ == '__main__':
unittest.main()
9 changes: 5 additions & 4 deletions tests/test_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

TO DO
=====
NONE


Functions Tested
Expand Down Expand Up @@ -32,10 +33,10 @@ def verify_key(self)
class TestAPI(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.key = os.environ.get('YT_KEY')
cls.wrong_key = 'xxxxxxxxx'
cls.yt = YoutubeDataApi(cls.key)
def setUpClass():
self.key = os.environ.get('YT_KEY')
self.wrong_key = 'xxxxxxxxx'
self.yt = YoutubeDataApi(cls.key)

#Verified by Megan Brown on 11/30/2018
def test_init(self):
Expand Down