diff --git a/.travis.yml b/.travis.yml index 6484d30d3..197c288b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ script: - msgcmp resources/language/resource.language.{nl_nl,en_gb}/strings.po #- kodi-addon-checker . --branch=krypton #- kodi-addon-checker . --branch=leia +- proxy.py & - coverage run -m unittest discover - coverage run -a test/run.py / diff --git a/Makefile b/Makefile index 786a2efb3..94d5ae8d2 100644 --- a/Makefile +++ b/Makefile @@ -45,9 +45,12 @@ addon: clean kodi-addon-checker . --branch=krypton kodi-addon-checker . --branch=leia -unit: +unit: clean @echo -e "$(white)=$(blue) Starting unit tests$(reset)" + -pkill -ef proxy.py + proxy.py & python -m unittest discover + pkill -ef proxy.py run: @echo -e "$(white)=$(blue) Run CLI$(reset)" @@ -61,6 +64,7 @@ zip: clean clean: find . -name '*.pyc' -type f -delete + find . -name '*.pyo' -type f -delete find . -name '__pycache__' -type d -delete rm -rf .pytest_cache/ .tox/ rm -f *.log test/userdata/tokens/*.tkn diff --git a/requirements.txt b/requirements.txt index e795135ba..fab148f62 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,7 @@ codecov git+git://github.com/emilsvennesson/script.module.inputstreamhelper.git@master#egg=inputstreamhelper kodi-addon-checker polib +proxy.py python-dateutil pylint git+git://github.com/dagwieers/kodi-plugin-routing.git@setup#egg=routing diff --git a/test/test_proxy.py b/test/test_proxy.py new file mode 100644 index 000000000..498714ac7 --- /dev/null +++ b/test/test_proxy.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +# pylint: disable=duplicate-code,invalid-name,missing-docstring,protected-access + +from __future__ import absolute_import, division, print_function, unicode_literals +import unittest +import addon + +xbmc = __import__('xbmc') +xbmcaddon = __import__('xbmcaddon') +xbmcgui = __import__('xbmcgui') +xbmcvfs = __import__('xbmcvfs') + + +plugin = addon.plugin + + +class TestProxy(unittest.TestCase): + def setUp(self): + xbmc.GLOBAL_SETTINGS['network.usehttpproxy'] = True + xbmc.GLOBAL_SETTINGS['network.httpproxytype'] = 0 + xbmc.GLOBAL_SETTINGS['network.httpproxyserver'] = '127.0.0.1' + xbmc.GLOBAL_SETTINGS['network.httpproxyport'] = '8899' + + def tearDown(self): + xbmc.GLOBAL_SETTINGS['network.usehttpproxy'] = False + + # Delete tokens method: '/tokens/delete' + def test_clear_cookies_route(self): + plugin.run(['plugin://plugin.video.vrt.nu/tokens/delete', '0', '']) + self.assertEqual(plugin.url_for(addon.delete_tokens), 'plugin://plugin.video.vrt.nu/tokens/delete') + + # Delete cache method: '/cache/delete' + def test_invalidate_caches_route(self): + plugin.run(['plugin://plugin.video.vrt.nu/cache/delete', '0', '']) + self.assertEqual(plugin.url_for(addon.delete_cache), 'plugin://plugin.video.vrt.nu/cache/delete') + + # A-Z menu: '/programs' + def test_az_menu(self): + plugin.run(['plugin://plugin.video.vrt.nu/programs', '0', '']) + self.assertEqual(plugin.url_for(addon.programs), 'plugin://plugin.video.vrt.nu/programs') + + # Categories menu: '/categories' + def test_categories_menu(self): + plugin.run(['plugin://plugin.video.vrt.nu/categories', '0', '']) + self.assertEqual(plugin.url_for(addon.categories), 'plugin://plugin.video.vrt.nu/categories') + + # Categories programs menu: '/categories/' + def test_categories_tvshow_menu(self): + plugin.run(['plugin://plugin.video.vrt.nu/categories/docu', '0', '']) + self.assertEqual(plugin.url_for(addon.categories, category='docu'), 'plugin://plugin.video.vrt.nu/categories/docu') + + # Favorites menu: '/favorites' + def test_favorites(self): + plugin.run(['plugin://plugin.video.vrt.nu/favorites/programs', '0', '']) + self.assertEqual(plugin.url_for(addon.favorites_programs), 'plugin://plugin.video.vrt.nu/favorites/programs') diff --git a/test/userdata/search_history.json b/test/userdata/search_history.json index a7e79847b..9d4cc0b2d 100644 --- a/test/userdata/search_history.json +++ b/test/userdata/search_history.json @@ -1 +1 @@ -["winter", "dag", "de", "foobar"] \ No newline at end of file +["winter", "dag", "test", "foobar"] \ No newline at end of file