nficano commited on
Commit
9d41628
·
1 Parent(s): fa9247c

expanding test coverage

Browse files
Files changed (2) hide show
  1. pytube/api.py +0 -1
  2. tests/test_pytube.py +11 -1
pytube/api.py CHANGED
@@ -90,7 +90,6 @@ class YouTube(object):
90
  video_id = parse_qs(qs).get('v')
91
  if video_id:
92
  return video_id.pop()
93
- return False
94
 
95
  @property
96
  def filename(self):
 
90
  video_id = parse_qs(qs).get('v')
91
  if video_id:
92
  return video_id.pop()
 
93
 
94
  @property
95
  def filename(self):
tests/test_pytube.py CHANGED
@@ -6,7 +6,7 @@ import mock
6
  from nose.tools import eq_, raises
7
  from pytube import api
8
  from pytube.exceptions import MultipleObjectsReturned, AgeRestricted, \
9
- DoesNotExist
10
 
11
 
12
  class TestPytube(object):
@@ -122,3 +122,13 @@ class TestPytube(object):
122
  warnings.simplefilter("always")
123
  self.yt.videos
124
  eq_(len(w), 1)
 
 
 
 
 
 
 
 
 
 
 
6
  from nose.tools import eq_, raises
7
  from pytube import api
8
  from pytube.exceptions import MultipleObjectsReturned, AgeRestricted, \
9
+ DoesNotExist, PytubeError
10
 
11
 
12
  class TestPytube(object):
 
122
  warnings.simplefilter("always")
123
  self.yt.videos
124
  eq_(len(w), 1)
125
+
126
+ def test_get_json_offset(self):
127
+ """Find the offset in the html for where the js starts"""
128
+ offset = self.yt._get_json_offset(self.mock_html)
129
+ eq_(offset, 312)
130
+
131
+ @raises(PytubeError)
132
+ def test_get_json_offset_with_bad_html(self):
133
+ """Raise exception if json offset cannot be found"""
134
+ self.yt._get_json_offset('asdfasdf')