Update test_generic.py

This commit is contained in:
mac12m99
2020-07-25 23:45:05 +02:00
committed by GitHub
parent e81dfd1d8c
commit d559ef8432
+17 -17
View File
@@ -3,9 +3,6 @@ import os
import sys import sys
import unittest import unittest
import HtmlTestRunner
import parameterized
import xbmc import xbmc
@@ -22,6 +19,9 @@ def add_on_info(*args, **kwargs):
# override # override
xbmc.get_add_on_info_from_calling_script = add_on_info xbmc.get_add_on_info_from_calling_script = add_on_info
import HtmlTestRunner
import parameterized
from platformcode import config, logger from platformcode import config, logger
config.set_setting('tmdb_active', False) config.set_setting('tmdb_active', False)
@@ -126,7 +126,7 @@ chNumRis = {
servers = [] servers = []
channels = [] channels = []
channel_list = channelselector.filterchannels("all") channel_list = channelselector.filterchannels("all")[:1]
ret = [] ret = []
for chItem in channel_list: for chItem in channel_list:
try: try:
@@ -201,30 +201,30 @@ class GenericChannelTest(unittest.TestCase):
title, itemlist in ch['menuItemlist'].items()]) title, itemlist in ch['menuItemlist'].items()])
class GenericChannelMenuItemTest(unittest.TestCase): class GenericChannelMenuItemTest(unittest.TestCase):
def test_menu(self): def test_menu(self):
print 'testing ' + self.ch + ' --> ' + title print 'testing ' + self.ch + ' --> ' + self.title
self.assertTrue(itemlist, 'channel ' + self.ch + ' -> ' + title + ' is empty') self.assertTrue(itemlist, 'channel ' + self.ch + ' -> ' + self.title + ' is empty')
self.assertTrue(self.serversFound, self.assertTrue(self.serversFound,
'channel ' + self.ch + ' -> ' + title + ' has no servers on all results') 'channel ' + self.ch + ' -> ' + self.title + ' has no servers on all results')
if self.ch in chNumRis: # i know how much results should be if self.ch in chNumRis: # i know how much results should be
for content in chNumRis[self.ch]: for content in chNumRis[self.ch]:
if content in title: if content in self.title:
risNum = len([i for i in itemlist if not i.nextPage]) # not count nextpage risNum = len([i for i in itemlist if not i.nextPage]) # not count nextpage
self.assertEqual(chNumRis[self.ch][content], risNum, self.assertEqual(chNumRis[self.ch][content], risNum,
'channel ' + self.ch + ' -> ' + title + ' returned wrong number of results') 'channel ' + self.ch + ' -> ' + self.title + ' returned wrong number of results')
break break
for resIt in itemlist: for resIt in itemlist:
print resIt.title + ' -> ' + resIt.url print resIt.self.title + ' -> ' + resIt.url
self.assertLess(len(resIt.fulltitle), 110, self.assertLess(len(resIt.fulltitle), 110,
'channel ' + self.ch + ' -> ' + title + ' might contain wrong titles\n' + resIt.fulltitle) 'channel ' + self.ch + ' -> ' + self.title + ' might contain wrong titles\n' + resIt.fulltitle)
if resIt.url: if resIt.url:
self.assertIsInstance(resIt.url, str, self.assertIsInstance(resIt.url, str,
'channel ' + self.ch + ' -> ' + title + ' -> ' + resIt.title + ' contain non-string url') 'channel ' + self.ch + ' -> ' + self.title + ' -> ' + resIt.title + ' contain non-string url')
self.assertIsNotNone(re.match(validUrlRegex, resIt.url), self.assertIsNotNone(re.match(validUrlRegex, resIt.url),
'channel ' + self.ch + ' -> ' + title + ' -> ' + resIt.title + ' might contain wrong url\n' + resIt.url) 'channel ' + self.ch + ' -> ' + self.title + ' -> ' + resIt.title + ' might contain wrong url\n' + resIt.url)
if 'year' in resIt.infoLabels and resIt.infoLabels['year']: if 'year' in resIt.infoLabels and resIt.infoLabels['year']:
msgYear = 'channel ' + self.ch + ' -> ' + title + ' might contain wrong infolabels year\n' + str( msgYear = 'channel ' + self.ch + ' -> ' + self.title + ' might contain wrong infolabels year\n' + str(
resIt.infoLabels['year']) resIt.infoLabels['year'])
self.assert_(type(resIt.infoLabels['year']) is int or resIt.infoLabels['year'].isdigit(), self.assert_(type(resIt.infoLabels['year']) is int or resIt.infoLabels['year'].isdigit(),
msgYear) msgYear)
@@ -234,7 +234,7 @@ class GenericChannelMenuItemTest(unittest.TestCase):
if resIt.title == typo(config.get_localized_string(30992), 'color kod bold'): # next page if resIt.title == typo(config.get_localized_string(30992), 'color kod bold'): # next page
nextPageItemlist = getattr(self.module, resIt.action)(resIt) nextPageItemlist = getattr(self.module, resIt.action)(resIt)
self.assertTrue(nextPageItemlist, self.assertTrue(nextPageItemlist,
'channel ' + self.ch + ' -> ' + title + ' has nextpage not working') 'channel ' + self.ch + ' -> ' + self.title + ' has nextpage not working')
print '\ntest passed' print '\ntest passed'
@@ -281,5 +281,5 @@ class GenericServerTest(unittest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(report_name='report', add_timestamp=False, unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(report_name='report', add_timestamp=False, combine_reports=True,
combine_reports=True, report_title='KoD Test Suite')) report_title='KoD Test Suite'), exit=False)