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-11-04 12:48:33 +01:00
|
|
|
from resources.lib.viervijfzes import ResolvedStream
|
2020-03-21 20:34:07 +01:00
|
|
|
from resources.lib.viervijfzes.auth import AuthApi
|
2021-02-17 07:42:24 +01:00
|
|
|
from resources.lib.viervijfzes.content import ContentApi, Program, Episode, CACHE_PREVENT, Category
|
2020-03-19 16:45:31 +01:00
|
|
|
|
2020-07-09 10:16:45 +02:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
class TestApi(unittest.TestCase):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(TestApi, self).__init__(*args, **kwargs)
|
2020-04-01 11:01:22 +02:00
|
|
|
auth = AuthApi(kodiutils.get_setting('username'), kodiutils.get_setting('password'), kodiutils.get_tokens_path())
|
|
|
|
self._api = ContentApi(auth, cache_path=kodiutils.get_cache_path())
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
def test_programs(self):
|
2021-02-01 08:53:13 +01:00
|
|
|
programs = self._api.get_programs()
|
|
|
|
self.assertIsInstance(programs, list)
|
|
|
|
self.assertIsInstance(programs[0], Program)
|
|
|
|
|
2021-02-17 07:42:24 +01:00
|
|
|
def test_popular_programs(self):
|
|
|
|
for brand in [None, 'vier', 'vijf', 'zes', 'goplay']:
|
|
|
|
programs = self._api.get_popular_programs(brand)
|
|
|
|
self.assertIsInstance(programs, list)
|
|
|
|
self.assertIsInstance(programs[0], Program)
|
|
|
|
|
|
|
|
def test_recommendations(self):
|
|
|
|
categories = self._api.get_recommendation_categories()
|
|
|
|
self.assertIsInstance(categories, list)
|
|
|
|
|
|
|
|
def test_categories(self):
|
|
|
|
categories = self._api.get_categories()
|
|
|
|
self.assertIsInstance(categories, list)
|
|
|
|
self.assertIsInstance(categories[0], Category)
|
|
|
|
|
|
|
|
programs = self._api.get_category_content(int(categories[0].uuid))
|
|
|
|
self.assertIsInstance(programs, list)
|
|
|
|
self.assertIsInstance(programs[0], Program)
|
2020-04-20 08:59:10 +02:00
|
|
|
|
2020-03-19 16:45:31 +01:00
|
|
|
def test_episodes(self):
|
2021-02-01 08:53:13 +01:00
|
|
|
for program in ['auwch', 'zo-man-zo-vrouw']:
|
|
|
|
program = self._api.get_program(program, cache=CACHE_PREVENT)
|
2020-03-19 16:45:31 +01:00
|
|
|
self.assertIsInstance(program, Program)
|
|
|
|
self.assertIsInstance(program.seasons, dict)
|
|
|
|
self.assertIsInstance(program.episodes, list)
|
|
|
|
self.assertIsInstance(program.episodes[0], Episode)
|
2020-03-23 16:30:25 +01:00
|
|
|
|
2020-04-20 08:59:10 +02:00
|
|
|
def test_clips(self):
|
2022-10-16 15:32:56 +02:00
|
|
|
for program in ['de-tafel-van-vier']:
|
2021-02-01 08:53:13 +01:00
|
|
|
program = self._api.get_program(program, extract_clips=True, cache=CACHE_PREVENT)
|
2020-04-20 08:59:10 +02:00
|
|
|
|
|
|
|
self.assertIsInstance(program.clips, list)
|
|
|
|
self.assertIsInstance(program.clips[0], Episode)
|
|
|
|
|
2021-02-01 08:53:13 +01:00
|
|
|
episode = self._api.get_episode(program.clips[0].path, cache=CACHE_PREVENT)
|
2020-04-20 08:59:10 +02:00
|
|
|
self.assertIsInstance(episode, Episode)
|
|
|
|
|
2020-03-24 22:20:24 +01:00
|
|
|
@unittest.skipUnless(kodiutils.get_setting('username') and kodiutils.get_setting('password'), 'Skipping since we have no credentials.')
|
2020-03-19 16:45:31 +01:00
|
|
|
def test_get_stream(self):
|
2021-02-01 08:53:13 +01:00
|
|
|
program = self._api.get_program('auwch')
|
2020-03-25 07:50:10 +01:00
|
|
|
self.assertIsInstance(program, Program)
|
2020-03-22 10:30:23 +01:00
|
|
|
|
2020-03-25 07:50:10 +01:00
|
|
|
episode = program.episodes[0]
|
2020-11-04 12:48:33 +01:00
|
|
|
resolved_stream = self._api.get_stream_by_uuid(episode.uuid)
|
|
|
|
self.assertIsInstance(resolved_stream, ResolvedStream)
|
|
|
|
|
|
|
|
@unittest.skipUnless(kodiutils.get_setting('username') and kodiutils.get_setting('password'), 'Skipping since we have no credentials.')
|
|
|
|
def test_get_drm_stream(self):
|
2022-10-16 15:36:00 +02:00
|
|
|
resolved_stream = self._api.get_stream_by_uuid('62e04ab5-1f3c-4385-ad7a-e2943ddb1849') # https://www.goplay.be/video/ncis-los-angeles/ncis-los-angeles-s10/ncis-los-angeles-s10-aflevering-12
|
2020-11-04 12:48:33 +01:00
|
|
|
self.assertIsInstance(resolved_stream, ResolvedStream)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|