Skip to content

Commit

Permalink
update unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
willforde committed Aug 30, 2018
1 parent e89434d commit 82da1fc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion script.module.codequick/lib/codequick/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def ytdl_logger(record):
raise RuntimeError(stored_errors[0])

@staticmethod
def extract_youtube(source):
def extract_youtube(source): # pragma: no cover
# TODO: Remove this method as soon as I found out for sure that youtube.dl works on kodi for Xbox
import htmlement
import urlquick
Expand Down
15 changes: 7 additions & 8 deletions script.module.codequick/lib/codequick/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,15 @@ def _parse_po(self): # type: () -> dict
strings_po = strings_po.decode("utf8") if isinstance(strings_po, bytes) else strings_po

# Check if strings.po actrally exists first
if not os.path.exists(strings_po):
return {}
if os.path.exists(strings_po): # pragma: no branch
with open(strings_po, "rb") as fo:
raw_strings = fo.read()

with open(strings_po, "rb") as fo:
raw_strings = fo.read()
# Parse strings using Regular Expressions
res = u"^msgctxt\s+[\"']#(\d+?)[\"']$[\n\r]^msgid\s+[\"'](.+?)[\"']$"
data = re.findall(res, raw_strings.decode("utf8"), re.MULTILINE | re.UNICODE)
self._strings.update((key, int(value)) for value, key in data)

# Parse strings using Regular Expressions
res = u"^msgctxt\s+[\"']#(\d+?)[\"']$[\n\r]^msgid\s+[\"'](.+?)[\"']$"
data = re.findall(res, raw_strings.decode("utf8"), re.MULTILINE | re.UNICODE)
self._strings.update((key, int(value)) for value, key in data)
return self._strings


Expand Down
11 changes: 9 additions & 2 deletions tests/test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,15 @@ def test_notify(self):
def test_localize(self):
self.assertEqual(self.script.localize(30001), "")

def test_localize_novideo(self):
self.assertEqual(self.script.localize(32401), "Unable to resolve url")
def test_localize_allvideos(self):
self.assertEqual("All Videos", self.script.localize(32003))

def test_localize_allvideos_gettext(self):
self.assertEqual(self.script.localize("All Videos"), "All Videos")

def test_localize_allvideos_gettext_non_exist(self):
with self.assertRaises(KeyError):
self.script.localize("All V")

def test_localize_nodata(self):
self.assertEqual(self.script.localize(33077), "No data found!")
Expand Down
6 changes: 3 additions & 3 deletions tests/test_youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def test_playlist_playlist_single_page(self):
self.assertGreaterEqual(len(ret), 10)

def test_playlist_playlist_muilti_page(self):
ret = route_caller(youtube.Playlist, "PLGe_S5n7MjT36EUYItEv7Wi3Wkz4pZU7o", loop=False)
ret = route_caller(youtube.Playlist, "PL8mG-RkN2uTx1lbFS8z8wRYS3RrHCp8TG", loop=False)
self.assertGreaterEqual(len(ret), 50)

def test_playlist_playlist_loop(self):
ret = route_caller(youtube.Playlist, "PLGe_S5n7MjT36EUYItEv7Wi3Wkz4pZU7o", loop=True)
self.assertGreaterEqual(len(ret), 250)
ret = route_caller(youtube.Playlist, "PL8mG-RkN2uTx1lbFS8z8wRYS3RrHCp8TG", loop=True)
self.assertGreaterEqual(len(ret), 66)

def test_related(self):
ret = route_caller(youtube.Related, "-QEXPO9zgX8")
Expand Down

0 comments on commit 82da1fc

Please sign in to comment.