2020-03-19 16:45:31 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
""" Tests for EPG API """
|
|
|
|
|
|
|
|
# pylint: disable=missing-docstring,no-self-use
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import unittest
|
|
|
|
from datetime import date
|
|
|
|
|
2020-04-01 11:01:22 +02:00
|
|
|
from resources.lib import kodiutils
|
2020-03-19 16:45:31 +01:00
|
|
|
from resources.lib.viervijfzes.content import ContentApi, Episode
|
|
|
|
from resources.lib.viervijfzes.epg import EpgApi, EpgProgram
|
|
|
|
|
2020-07-09 10:16:45 +02:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
class TestEpg(unittest.TestCase):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(TestEpg, self).__init__(*args, **kwargs)
|
2020-03-22 10:30:23 +01:00
|
|
|
self._epg = EpgApi()
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
def test_vier_today(self):
|
2021-02-01 08:53:13 +01:00
|
|
|
programs = self._epg.get_epg('Play4', date.today().strftime('%Y-%m-%d'))
|
2020-03-19 16:45:31 +01:00
|
|
|
self.assertIsInstance(programs, list)
|
|
|
|
self.assertIsInstance(programs[0], EpgProgram)
|
|
|
|
|
|
|
|
def test_vijf_today(self):
|
2021-02-01 08:53:13 +01:00
|
|
|
programs = self._epg.get_epg('Play5', date.today().strftime('%Y-%m-%d'))
|
2020-03-19 16:45:31 +01:00
|
|
|
self.assertIsInstance(programs, list)
|
|
|
|
self.assertIsInstance(programs[0], EpgProgram)
|
|
|
|
|
|
|
|
def test_zes_today(self):
|
2021-02-01 08:53:13 +01:00
|
|
|
programs = self._epg.get_epg('Play6', date.today().strftime('%Y-%m-%d'))
|
2020-03-19 16:45:31 +01:00
|
|
|
self.assertIsInstance(programs, list)
|
|
|
|
self.assertIsInstance(programs[0], EpgProgram)
|
|
|
|
|
|
|
|
def test_unknown_today(self):
|
|
|
|
with self.assertRaises(Exception):
|
2020-03-22 10:30:23 +01:00
|
|
|
self._epg.get_epg('vtm', date.today().strftime('%Y-%m-%d'))
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
def test_vier_out_of_range(self):
|
2021-02-01 08:53:13 +01:00
|
|
|
programs = self._epg.get_epg('Play4', '2020-01-01')
|
2020-03-19 16:45:31 +01:00
|
|
|
self.assertEqual(programs, [])
|
|
|
|
|
|
|
|
def test_play_video_from_epg(self):
|
2021-02-01 08:53:13 +01:00
|
|
|
epg_programs = self._epg.get_epg('Play4', 'yesterday')
|
2020-03-19 16:45:31 +01:00
|
|
|
epg_program = [program for program in epg_programs if program.video_url][0]
|
|
|
|
|
|
|
|
# Lookup the Episode data since we don't have an UUID
|
2020-04-01 11:01:22 +02:00
|
|
|
api = ContentApi(cache_path=kodiutils.get_cache_path())
|
2021-02-01 08:53:13 +01:00
|
|
|
episode = api.get_episode(epg_program.video_url)
|
2020-03-19 16:45:31 +01:00
|
|
|
self.assertIsInstance(episode, Episode)
|
|
|
|
|
2020-06-09 10:51:59 +02:00
|
|
|
# def test_map_epg_genre(self):
|
|
|
|
# genres = []
|
|
|
|
# for channel in ['vier', 'vijf', 'zes']:
|
|
|
|
# for day in ['yesterday', 'today', 'tomorrow']:
|
|
|
|
# programs = self._epg.get_epg(channel, day)
|
|
|
|
#
|
|
|
|
# for program in programs:
|
|
|
|
# if program.genre not in genres:
|
|
|
|
# genres.append(program.genre)
|
|
|
|
#
|
|
|
|
# print(genres)
|
|
|
|
#
|
2020-03-19 16:45:31 +01:00
|
|
|
|
2020-07-09 10:16:45 +02:00
|
|
|
|
2020-03-19 16:45:31 +01:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|