Allow to run tests without authentication

This commit is contained in:
Michaël Arnauts 2020-03-24 22:20:24 +01:00
parent f15adcf7f3
commit fd59759892
3 changed files with 3 additions and 11 deletions

View File

@ -37,6 +37,7 @@ class TestApi(unittest.TestCase):
program_by_uuid = self._api.get_program_by_uuid(program.uuid)
self.assertIsInstance(program_by_uuid, Program)
@unittest.skipUnless(kodiutils.get_setting('username') and kodiutils.get_setting('password'), 'Skipping since we have no credentials.')
def test_get_stream(self):
program = self._api.get_program('vier', 'auwch')
episode = program.episodes[0]
@ -44,8 +45,6 @@ class TestApi(unittest.TestCase):
video = self._api.get_stream_by_uuid(episode.uuid)
self.assertTrue(video)
_LOGGER.info('Got video URL: %s', video)
if __name__ == '__main__':
unittest.main()

View File

@ -18,6 +18,7 @@ class TestAuth(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(TestAuth, self).__init__(*args, **kwargs)
@unittest.skipUnless(kodiutils.get_setting('username') and kodiutils.get_setting('password'), 'Skipping since we have no credentials.')
def test_login(self):
# Clear any cache we have
AuthApi.clear_tokens()

View File

@ -9,8 +9,6 @@ import logging
import unittest
from datetime import date
from resources.lib import kodiutils
from resources.lib.viervijfzes.auth import AuthApi
from resources.lib.viervijfzes.content import ContentApi, Episode
from resources.lib.viervijfzes.epg import EpgApi, EpgProgram
@ -49,17 +47,11 @@ class TestEpg(unittest.TestCase):
epg_programs = self._epg.get_epg('vier', date.today().strftime('%Y-%m-%d'))
epg_program = [program for program in epg_programs if program.video_url][0]
auth = AuthApi(kodiutils.get_setting('username'), kodiutils.get_setting('password'))
api = ContentApi(auth)
# Lookup the Episode data since we don't have an UUID
api = ContentApi()
episode = api.get_episode(epg_program.channel, epg_program.video_url)
self.assertIsInstance(episode, Episode)
# Get stream based on the Episode's UUID
video = api.get_stream_by_uuid(episode.uuid)
self.assertTrue(video)
if __name__ == '__main__':
unittest.main()