Basename Combinator Tests passed
This commit is contained in:
@@ -10,16 +10,17 @@ from .basename_combinator import BasenameCombinator
|
||||
from .indicator_combinator import IndicatorCombinator
|
||||
from .label_combinator import LabelCombinator
|
||||
from .title_combinator import TitleCombinator
|
||||
from .site_combinator import SiteCombinator
|
||||
from .release_combinator import ReleaseCombinator
|
||||
from .show_combinator import ShowCombinator
|
||||
|
||||
|
||||
class BasenameCombinator2(BasenameCombinator):
|
||||
"""documentation_site"""
|
||||
"""show[_indicator]_group"""
|
||||
|
||||
VARIANT = 'B2'
|
||||
|
||||
# def __init__(self, SubCombinators: dict = {}, context = None):
|
||||
def __init__(self, context = None):
|
||||
|
||||
self._context = context
|
||||
self._logger = context['logger']
|
||||
self._reportLogger = context['report_logger']
|
||||
@@ -27,40 +28,132 @@ class BasenameCombinator2(BasenameCombinator):
|
||||
def getVariant(self):
|
||||
return BasenameCombinator2.VARIANT
|
||||
|
||||
def getPayload(self):
|
||||
return ''
|
||||
#
|
||||
# SHOW_LIST = [
|
||||
# 'Boruto: Naruto Next Generations (2017)',
|
||||
# 'The Rising of the Shield Hero (2019)',
|
||||
# 'Scrubs - Die Anfänger (2001)'
|
||||
# ]
|
||||
#
|
||||
# RELEASE_LIST = [
|
||||
# ".GerEngSub.AAC.1080pINDICATOR.WebDL.x264-Tanuki",
|
||||
# ".German.AC3.DL.1080pINDICATOR.BluRay.x264-AST4u",
|
||||
# "-720pINDICATOR"
|
||||
# ]
|
||||
|
||||
|
||||
def getPayload(self,
|
||||
indicator = '',
|
||||
label = '',
|
||||
show = '',
|
||||
release = ''):
|
||||
|
||||
if label:
|
||||
basename = label
|
||||
expectedBasename = label
|
||||
if indicator:
|
||||
basename += f"_{indicator}"
|
||||
expectedBasename += f"_{indicator}"
|
||||
else:
|
||||
basename = show+release
|
||||
expectedBasename = basename
|
||||
|
||||
return {'basename': basename,
|
||||
'label': label,
|
||||
'expectedBasename': expectedBasename}
|
||||
|
||||
|
||||
def assertFunc(self,
|
||||
indicator = '',
|
||||
label = '',
|
||||
show = '',
|
||||
release = ''):
|
||||
|
||||
def f(testObj: dict = {}):
|
||||
|
||||
if not 'filenames' in testObj.keys():
|
||||
raise KeyError("testObj does not contain key 'filenames'")
|
||||
|
||||
fNames = testObj['filenames']
|
||||
|
||||
assert len(fNames) == 1, "More than one result file was created"
|
||||
|
||||
resultFilename = fNames[0]
|
||||
|
||||
fTokens = resultFilename.split('.')
|
||||
|
||||
resultBasename = '.'.join(fTokens[:-1])
|
||||
resultExtension = fTokens[-1]
|
||||
|
||||
if not indicator and not label:
|
||||
assert resultBasename == show+release, f"Result basename is not {show+release}"
|
||||
elif not indicator and label:
|
||||
assert resultBasename == label, f"Result basename is not {label}"
|
||||
elif indicator and not label:
|
||||
assert resultBasename == show+release, f"Result basename is not {show+release}"
|
||||
elif indicator and label:
|
||||
assert resultBasename == f"{label}_{indicator}", f"Result basename is not {label}_{indicator}"
|
||||
|
||||
return f
|
||||
|
||||
def assertFunc(self, mediaDescriptor: MediaDescriptor):
|
||||
pass
|
||||
|
||||
def shouldFail(self):
|
||||
return False
|
||||
|
||||
def getYield(self):
|
||||
|
||||
ic = IndicatorCombinator(self._context)
|
||||
sc = ShowCombinator(self._context)
|
||||
|
||||
for L in LabelCombinator.getAllClassReferences():
|
||||
# for I in IndicatorCombinator.getAllClassReferences():
|
||||
# for S in SiteCombinator.getAllClassReferences():
|
||||
# for T in TitleCombinator.getAllClassReferences():
|
||||
#
|
||||
for iy in ic.getYield():
|
||||
|
||||
l = L(self._context)
|
||||
indicator = iy['indicator']
|
||||
indicatorVariant = iy['variant']
|
||||
|
||||
yieldObj = {}
|
||||
rc = ReleaseCombinator(self._context, indicator=indicator)
|
||||
|
||||
yieldObj['identifier'] = self.getIdentifier()
|
||||
for sy in sc.getYield():
|
||||
for ry in rc.getYield():
|
||||
|
||||
yieldObj['variants'] = [self.getVariant(),
|
||||
l.getVariant()]
|
||||
l = L(self._context)
|
||||
|
||||
yieldObj['payload'] = {'label': l.getPayload()}
|
||||
show = sy['show']
|
||||
showVariant = sy['variant']
|
||||
|
||||
yieldObj['assertSelectors'] = ['B', 'L']
|
||||
release = ry['release']
|
||||
releaseVariant = ry['variant']
|
||||
|
||||
yieldObj['assertFuncs'] = [self.assertFunc,
|
||||
l.assertFunc]
|
||||
yieldObj = {}
|
||||
|
||||
yieldObj['shouldFail'] = (self.shouldFail()
|
||||
| l.shouldFail())
|
||||
yieldObj['identifier'] = self.getIdentifier()
|
||||
|
||||
yield yieldObj
|
||||
yieldObj['variants'] = [self.getVariant(),
|
||||
l.getVariant(),
|
||||
indicatorVariant,
|
||||
showVariant,
|
||||
releaseVariant]
|
||||
|
||||
yieldObj['payload'] = self.getPayload(indicator = indicator,
|
||||
label = l.getPayload(),
|
||||
show = show,
|
||||
release = release)
|
||||
|
||||
yieldObj['assertSelectors'] = ['B', 'L', 'I', 'S', 'R']
|
||||
|
||||
yieldObj['assertFuncs'] = [self.assertFunc(indicator,
|
||||
l.getPayload(),
|
||||
show = show,
|
||||
release = release),
|
||||
l.assertFunc,
|
||||
ic.assertFunc,
|
||||
sc.assertFunc,
|
||||
rc.assertFunc]
|
||||
|
||||
yieldObj['shouldFail'] = (self.shouldFail()
|
||||
| l.shouldFail()
|
||||
| ic.shouldFail()
|
||||
| sc.shouldFail()
|
||||
| rc.shouldFail())
|
||||
|
||||
yield yieldObj
|
||||
|
||||
Reference in New Issue
Block a user