Fix animesaturn, dreamsub, polpotv.
Alcune modifiche e migliorati i test
This commit is contained in:
140
tests.py
140
tests.py
@@ -5,6 +5,7 @@ import unittest
|
||||
import parameterized
|
||||
|
||||
from platformcode import config
|
||||
|
||||
librerias = os.path.join(config.get_runtime_path(), 'lib')
|
||||
sys.path.insert(0, librerias)
|
||||
from core.support import typo
|
||||
@@ -12,57 +13,96 @@ from core.item import Item
|
||||
import channelselector
|
||||
from core import servertools
|
||||
import re
|
||||
|
||||
validUrlRegex = re.compile(
|
||||
r'^(?:http|ftp)s?://' # http:// or https://
|
||||
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
|
||||
r'localhost|' #localhost...
|
||||
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
|
||||
r'(?::\d+)?' # optional port
|
||||
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
|
||||
r'^(?:http|ftp)s?://' # http:// or https://
|
||||
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain...
|
||||
r'localhost|' # localhost...
|
||||
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
|
||||
r'(?::\d+)?' # optional port
|
||||
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
|
||||
|
||||
chBlackList = ['url']
|
||||
chNumRis = {
|
||||
'altadefinizione01': {
|
||||
'film': 20
|
||||
'Film': 20
|
||||
},
|
||||
'altadefinizione01_link': {
|
||||
'film': 16,
|
||||
'serie': 16,
|
||||
},
|
||||
'Film': 16,
|
||||
'Serie TV': 16,
|
||||
},
|
||||
'altadefinizioneclick': {
|
||||
'film': 36,
|
||||
'serie': 12,
|
||||
},
|
||||
'Film': 36,
|
||||
'Serie TV': 12,
|
||||
},
|
||||
'casacinema': {
|
||||
'film': 10,
|
||||
'serie': 10,
|
||||
},
|
||||
'Film': 10,
|
||||
'Serie TV': 10,
|
||||
},
|
||||
'cineblog01': {
|
||||
'film': 12,
|
||||
'serie': 13
|
||||
},
|
||||
'Film': 12,
|
||||
'Serie TV': 13
|
||||
},
|
||||
'cinemalibero': {
|
||||
'film': 20,
|
||||
'serie': 20,
|
||||
},
|
||||
'Film': 20,
|
||||
'Serie TV': 20,
|
||||
},
|
||||
'cinetecadibologna': {
|
||||
'film': 10
|
||||
},
|
||||
'Film': 10
|
||||
},
|
||||
'eurostreaming': {
|
||||
'serie': 18
|
||||
},
|
||||
'filmpertutti': {
|
||||
'film': 24,
|
||||
'serie': 24,
|
||||
},
|
||||
'guardaserieclick': {
|
||||
'da controllare': 0
|
||||
},
|
||||
'Serie TV': 18
|
||||
},
|
||||
'Filmpertutti': {
|
||||
'Film': 24,
|
||||
'Serie TV': 24,
|
||||
},
|
||||
'guardaSerie TVclick': {
|
||||
'da controllare': 0
|
||||
},
|
||||
'hd4me': {
|
||||
'film': 10
|
||||
},
|
||||
'Film': 10
|
||||
},
|
||||
'ilgeniodellostreaming': {
|
||||
'Film': 30,
|
||||
'Serie TV': 30
|
||||
},
|
||||
'italiaserie': {
|
||||
'Serie TV': 20
|
||||
},
|
||||
'casacinemaInfo': {
|
||||
'Film': 150
|
||||
},
|
||||
'netfreex': {
|
||||
'Film': 30,
|
||||
'Serie TV': 30
|
||||
},
|
||||
'piratestreaming': {
|
||||
'Film': 24,
|
||||
'Serie TV': 24
|
||||
},
|
||||
'polpotv': {
|
||||
'Film': 12,
|
||||
'Serie TV': 12
|
||||
},
|
||||
'streamingaltadefinizione': {
|
||||
'Film': 30,
|
||||
'Serie TV': 30
|
||||
},
|
||||
'seriehd': {
|
||||
'Serie TV': 12
|
||||
},
|
||||
'serietvonline': {
|
||||
'Film': 35,
|
||||
'Serie TV': 35
|
||||
},
|
||||
'tantifilm': {
|
||||
'Film': 20,
|
||||
'Serie TV': 20
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def getChannels():
|
||||
channel_list = channelselector.filterchannels("all")
|
||||
ret = []
|
||||
@@ -72,7 +112,9 @@ def getChannels():
|
||||
ret.append({'ch': ch})
|
||||
return ret
|
||||
|
||||
|
||||
from specials import news
|
||||
|
||||
dictNewsChannels, any_active = news.get_channels_list()
|
||||
|
||||
srvLinkDict = {
|
||||
@@ -80,6 +122,7 @@ srvLinkDict = {
|
||||
"akvideo": ["https://akvideo.stream/video.php?file_code=23god95lrtqv"]
|
||||
}
|
||||
|
||||
|
||||
def getServers():
|
||||
server_list = servertools.get_servers_list()
|
||||
ret = []
|
||||
@@ -101,6 +144,7 @@ class GenericChannelTest(unittest.TestCase):
|
||||
self.assertTrue(mainlist, 'channel ' + self.ch + ' has no menu')
|
||||
|
||||
for it in mainlist:
|
||||
it.title = it.title.encode('ascii', 'ignore')
|
||||
if it.action == 'channel_config':
|
||||
hasChannelConfig = True
|
||||
continue
|
||||
@@ -108,18 +152,32 @@ class GenericChannelTest(unittest.TestCase):
|
||||
continue
|
||||
itemlist = getattr(self.module, it.action)(it)
|
||||
self.assertTrue(itemlist, 'channel ' + self.ch + ' -> ' + it.title + ' is empty')
|
||||
if self.ch in chNumRis: # so a priori quanti risultati dovrebbe dare
|
||||
for content in chNumRis[self.ch]:
|
||||
if content in it.title:
|
||||
risNum = len(itemlist) - 1 # - nextpage
|
||||
self.assertEqual(risNum, chNumRis[self.ch][content],
|
||||
'channel ' + self.ch + ' -> ' + it.title + ' returned ' + str(
|
||||
risNum) + ' results but should have returned ' + str(
|
||||
chNumRis[self.ch][content]))
|
||||
break
|
||||
|
||||
for resIt in itemlist:
|
||||
self.assertLess(len(resIt.fulltitle), 100, 'channel ' + self.ch + ' -> ' + it.title + ' might contain wrong titles\n' + resIt.fulltitle)
|
||||
self.assertLess(len(resIt.fulltitle), 100,
|
||||
'channel ' + self.ch + ' -> ' + it.title + ' might contain wrong titles\n' + resIt.fulltitle)
|
||||
if resIt.url:
|
||||
self.assertIsNotNone(re.match(validUrlRegex, resIt.url), 'channel ' + self.ch + ' -> ' + it.title + ' -> ' + resIt.title + ' might contain wrong url\n' + resIt.url)
|
||||
self.assertIsNotNone(re.match(validUrlRegex, resIt.url),
|
||||
'channel ' + self.ch + ' -> ' + it.title + ' -> ' + resIt.title + ' might contain wrong url\n' + resIt.url)
|
||||
if 'year' in resIt.infoLabels and resIt.infoLabels['year']:
|
||||
msgYear = 'channel ' + self.ch + ' -> ' + it.title + ' might contain wrong infolabels year\n' + str(resIt.infoLabels['year'])
|
||||
msgYear = 'channel ' + self.ch + ' -> ' + it.title + ' might contain wrong infolabels year\n' + str(
|
||||
resIt.infoLabels['year'])
|
||||
self.assert_(type(resIt.infoLabels['year']) is int or resIt.infoLabels['year'].isdigit(), msgYear)
|
||||
self.assert_(int(resIt.infoLabels['year']) > 1900 and int(resIt.infoLabels['year']) < 2100, msgYear)
|
||||
|
||||
if resIt.title == typo(config.get_localized_string(30992), 'color kod bold'): # next page
|
||||
nextPageItemlist = getattr(self.module, resIt.action)(resIt)
|
||||
self.assertTrue(nextPageItemlist, 'channel ' + self.ch + ' -> ' + it.title + ' has nextpage not working')
|
||||
self.assertTrue(nextPageItemlist,
|
||||
'channel ' + self.ch + ' -> ' + it.title + ' has nextpage not working')
|
||||
self.assertTrue(hasChannelConfig, 'channel ' + self.ch + ' has no channel config')
|
||||
|
||||
def test_newest(self):
|
||||
@@ -130,6 +188,7 @@ class GenericChannelTest(unittest.TestCase):
|
||||
self.assertTrue(itemlist, 'channel ' + self.ch + ' returned no news for category ' + cat)
|
||||
break
|
||||
|
||||
|
||||
#
|
||||
# @parameterized.parameterized_class(getServers())
|
||||
# class GenericServerTest(unittest.TestCase):
|
||||
@@ -155,4 +214,5 @@ class GenericChannelTest(unittest.TestCase):
|
||||
# self.assertEqual(requests.head(directUrl, headers=headers, timeout=15).status_code, 200, self.srv + ' scraper did not return valid url for link ' + link)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
config.set_setting('tmdb_active', False)
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user