plugin.video.viervijfzes/test/test_api.py

52 lines
1.8 KiB
Python
Raw Normal View History

2020-03-19 16:45:31 +01:00
# -*- coding: utf-8 -*-
""" Tests for Content API """
# pylint: disable=missing-docstring,no-self-use
from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import unittest
2020-03-21 20:34:07 +01:00
import resources.lib.kodiutils as kodiutils
2020-03-19 16:45:31 +01:00
from resources.lib.viervijfzes.content import ContentApi, Program, Episode
2020-03-21 20:34:07 +01:00
from resources.lib.viervijfzes.auth import AuthApi
2020-03-19 16:45:31 +01:00
_LOGGER = logging.getLogger('test-api')
class TestApi(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(TestApi, self).__init__(*args, **kwargs)
2020-03-22 10:30:23 +01:00
self._api = ContentApi()
2020-03-19 16:45:31 +01:00
def test_programs(self):
for channel in ['vier', 'vijf', 'zes']:
2020-03-22 10:30:23 +01:00
channels = self._api.get_programs(channel)
2020-03-19 16:45:31 +01:00
self.assertIsInstance(channels, list)
def test_episodes(self):
for channel, program in [('vier', 'auwch'), ('vijf', 'zo-man-zo-vrouw')]:
2020-03-22 10:30:23 +01:00
program = self._api.get_program(channel, program)
2020-03-19 16:45:31 +01:00
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)
def test_get_stream(self):
2020-03-22 10:30:23 +01:00
program = self._api.get_program('vier', 'auwch')
2020-03-19 16:45:31 +01:00
episode = program.episodes[0]
2020-03-22 10:30:23 +01:00
auth = AuthApi(kodiutils.get_setting('username'), kodiutils.get_setting('password'), kodiutils.get_tokens_path())
api_authed = ContentApi(auth.get_token())
video = api_authed.get_stream(episode.channel, episode.uuid)
2020-03-19 16:45:31 +01:00
self.assertTrue(video)
_LOGGER.info('Got video URL: %s', video)
if __name__ == '__main__':
unittest.main()