From 9b94ba381d45b2fcf706529616162f75c1b8e3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Arnauts?= Date: Mon, 23 Mar 2020 16:30:25 +0100 Subject: [PATCH] Improve code coverage (#9) * Improve code coverage testing --- .../resource.language.en_gb/strings.po | 8 +++ .../resource.language.nl_nl/strings.po | 8 +++ test/test_api.py | 5 +- test/test_routing.py | 64 +++++++++++++++++++ 4 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 test/test_routing.py diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index a558f5a..7e01c4a 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -14,6 +14,14 @@ msgctxt "#30002" msgid "Alphabetically sorted list of programs" msgstr "" +msgctxt "#30003" +msgid "Catalogue" +msgstr "" + +msgctxt "#30004" +msgid "TV Shows and Movies listed by category" +msgstr "" + msgctxt "#30007" msgid "Channels" msgstr "" diff --git a/resources/language/resource.language.nl_nl/strings.po b/resources/language/resource.language.nl_nl/strings.po index f98a5c5..20bf56b 100644 --- a/resources/language/resource.language.nl_nl/strings.po +++ b/resources/language/resource.language.nl_nl/strings.po @@ -15,6 +15,14 @@ msgctxt "#30002" msgid "Alphabetically sorted list of programs" msgstr "Volledige lijst van programma's" +msgctxt "#30003" +msgid "Catalogue" +msgstr "Catalogus" + +msgctxt "#30004" +msgid "TV Shows and Movies listed by category" +msgstr "Programma's en films per categorie" + msgctxt "#30007" msgid "Channels" msgstr "Kanalen" diff --git a/test/test_api.py b/test/test_api.py index 355c3ac..ac505e1 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -31,10 +31,11 @@ class TestApi(unittest.TestCase): program = self._api.get_program(channel, program) self.assertIsInstance(program, Program) self.assertIsInstance(program.seasons, dict) - # self.assertIsInstance(program.seasons[0], Season) self.assertIsInstance(program.episodes, list) self.assertIsInstance(program.episodes[0], Episode) - _LOGGER.info('Got program: %s', program) + + program_by_uuid = self._api.get_program_by_uuid(program.uuid) + self.assertIsInstance(program_by_uuid, Program) def test_get_stream(self): program = self._api.get_program('vier', 'auwch') diff --git a/test/test_routing.py b/test/test_routing.py new file mode 100644 index 0000000..ce6cbdb --- /dev/null +++ b/test/test_routing.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +""" Tests for Routing """ + +# pylint: disable=missing-docstring,no-self-use + +from __future__ import absolute_import, division, print_function, unicode_literals + +import unittest + +from resources.lib import addon + +xbmc = __import__('xbmc') +xbmcaddon = __import__('xbmcaddon') +xbmcgui = __import__('xbmcgui') +xbmcplugin = __import__('xbmcplugin') +xbmcvfs = __import__('xbmcvfs') + +routing = addon.routing + + +class TestRouting(unittest.TestCase): + """ Tests for Routing """ + + def __init__(self, *args, **kwargs): + super(TestRouting, self).__init__(*args, **kwargs) + + def setUp(self): + # Don't warn that we don't close our HTTPS connections, this is on purpose. + # warnings.simplefilter("ignore", ResourceWarning) + pass + + def test_main_menu(self): + routing.run([routing.url_for(addon.show_main_menu), '0', '']) + + def test_channels_menu(self): + routing.run([routing.url_for(addon.show_channels), '0', '']) + routing.run([routing.url_for(addon.show_channel_menu, channel='vier'), '0', '']) + + def test_catalog_menu(self): + routing.run([routing.url_for(addon.show_catalog), '0', '']) + + def test_catalog_channel_menu(self): + routing.run([routing.url_for(addon.show_catalog_channel, channel='vier'), '0', '']) + + def test_catalog_program_menu(self): + routing.run([routing.url_for(addon.show_catalog_program, channel='vier', program='de-mol'), '0', '']) + + def test_catalog_program_season_menu(self): + routing.run([routing.url_for(addon.show_catalog_program_season, channel='vier', program='de-mol', season=-1), '0', '']) + + def test_search_menu(self): + routing.run([routing.url_for(addon.show_search), '0', '']) + routing.run([routing.url_for(addon.show_search, query='de mol'), '0', '']) + + def test_tvguide_menu(self): + routing.run([routing.url_for(addon.show_tvguide_channel, channel='vier'), '0', '']) + routing.run([routing.url_for(addon.show_tvguide_detail, channel='vier', date='today'), '0', '']) + + def test_metadata_update(self): + routing.run([routing.url_for(addon.metadata_clean), '0', '']) + + +if __name__ == '__main__': + unittest.main()