From b9185b5b07bc379d3dd3adb27fbe7f304aaacf3e Mon Sep 17 00:00:00 2001 From: Maveno Date: Fri, 1 Nov 2024 23:25:46 +0100 Subject: [PATCH] nighl --- bin/ffx/test/basename_combinator.py | 33 ++++++++++ bin/ffx/test/basename_combinator_0.py | 84 ++++++++++++++++++++++++ bin/ffx/test/basename_combinator_1.py | 90 ++++++++++++++++++++++++++ bin/ffx/test/basename_combinator_2.py | 92 +++++++++++++++++++++++++++ bin/ffx/test/indicator_combinator.py | 26 ++++++++ bin/ffx/test/label_combinator.py | 36 +++++++++++ bin/ffx/test/label_combinator_0.py | 30 +++++++++ bin/ffx/test/label_combinator_1.py | 30 +++++++++ bin/ffx/test/site_combinator.py | 34 ++++++++++ bin/ffx/test/title_combinator.py | 28 ++++++++ 10 files changed, 483 insertions(+) create mode 100644 bin/ffx/test/basename_combinator.py create mode 100644 bin/ffx/test/basename_combinator_0.py create mode 100644 bin/ffx/test/basename_combinator_1.py create mode 100644 bin/ffx/test/basename_combinator_2.py create mode 100644 bin/ffx/test/indicator_combinator.py create mode 100644 bin/ffx/test/label_combinator.py create mode 100644 bin/ffx/test/label_combinator_0.py create mode 100644 bin/ffx/test/label_combinator_1.py create mode 100644 bin/ffx/test/site_combinator.py create mode 100644 bin/ffx/test/title_combinator.py diff --git a/bin/ffx/test/basename_combinator.py b/bin/ffx/test/basename_combinator.py new file mode 100644 index 0000000..31b3423 --- /dev/null +++ b/bin/ffx/test/basename_combinator.py @@ -0,0 +1,33 @@ +import os, sys, importlib, glob, inspect, itertools + +class BasenameCombinator(): + + IDENTIFIER = 'basename' + + def __init__(self, context = None): + self._context = context + self._logger = context['logger'] + self._reportLogger = context['report_logger'] + + def getIdentifier(self): + return BasenameCombinator.IDENTIFIER + + @staticmethod + def list(): + basePath = os.path.dirname(__file__) + return [os.path.basename(p)[20:-3] + for p + in glob.glob(f"{ basePath }/basename_combinator_*.py", recursive = True) + if p != __file__] + + @staticmethod + def getClassReference(identifier): + importlib.import_module(f"ffx.test.basename_combinator_{ identifier }") + for name, obj in inspect.getmembers(sys.modules[f"ffx.test.basename_combinator_{ identifier }"]): + #HINT: Excluding MediaCombinator as it seems to be included by import (?) + if inspect.isclass(obj) and name != 'BasenameCombinator' and name.startswith('BasenameCombinator'): + return obj + + @staticmethod + def getAllClassReferences(): + return [BasenameCombinator.getClassReference(i) for i in BasenameCombinator.list()] diff --git a/bin/ffx/test/basename_combinator_0.py b/bin/ffx/test/basename_combinator_0.py new file mode 100644 index 0000000..3d60513 --- /dev/null +++ b/bin/ffx/test/basename_combinator_0.py @@ -0,0 +1,84 @@ +import os, sys, importlib, glob, inspect, itertools + +from ffx.track_type import TrackType + +from ffx.track_descriptor import TrackDescriptor +from ffx.media_descriptor import MediaDescriptor + +from .basename_combinator import BasenameCombinator + +from .indicator_combinator import IndicatorCombinator + + +class BasenameCombinator0(BasenameCombinator): + + VARIANT = 'B0' + + # def __init__(self, SubCombinators: dict = {}, context = None): + def __init__(self, context = None): + self._context = context + self._logger = context['logger'] + self._reportLogger = context['report_logger'] + + def getVariant(self): + return BasenameCombinator0.VARIANT + + def getPayload(self): + return {} + + def assertFunc(self, testObj = {}): + pass + + def shouldFail(self): + return False + + def getYield(self): + + for MTC in MediaTagCombinator.getAllClassReferences(): + for DC2_A in DispositionCombinator2.getAllClassReferences(): + for TC2_A in TrackTagCombinator2.getAllClassReferences(): + for DC3_S in DispositionCombinator3.getAllClassReferences(): + for TC3_S in TrackTagCombinator3.getAllClassReferences(): + for J in JellyfinCombinator.getAllClassReferences(): + + j = J(self._context) + self._context['use_jellyfin'] = j.getPayload() + + dc2a = DC2_A(self._context) + tc2a = TC2_A(self._context) + dc3s = DC3_S(self._context) + tc3s = TC3_S(self._context) + mtc = MTC(self._context) + + yieldObj = {} + + yieldObj['identifier'] = self.getIdentifier() + yieldObj['variants'] = [self.getVariant(), + f"A:{dc2a.getVariant()}", + f"A:{tc2a.getVariant()}", + f"S:{dc3s.getVariant()}", + f"S:{tc3s.getVariant()}", + mtc.getVariant(), + j.getVariant()] + + yieldObj['payload'] = self.getPayload(dc2a.getPayload(), tc2a.getPayload(), dc3s.getPayload(), tc3s.getPayload()) + + yieldObj['assertSelectors'] = ['M', 'AD', 'AT', 'SD', 'ST', 'MT', 'J'] + + yieldObj['assertFuncs'] = [self.assertFunc, + dc2a.assertFunc, + tc2a.assertFunc, + dc3s.assertFunc, + tc3s.assertFunc, + mtc.assertFunc, + j.assertFunc] + + yieldObj['shouldFail'] = (self.shouldFail() + | dc2a.shouldFail() + | tc2a.shouldFail() + | dc3s.shouldFail() + | tc3s.shouldFail() + | mtc.shouldFail() + | j.shouldFail()) + + yield yieldObj diff --git a/bin/ffx/test/basename_combinator_1.py b/bin/ffx/test/basename_combinator_1.py new file mode 100644 index 0000000..7ab55f9 --- /dev/null +++ b/bin/ffx/test/basename_combinator_1.py @@ -0,0 +1,90 @@ +import os, sys, importlib, glob, inspect, itertools + +from ffx.track_type import TrackType + +from ffx.track_descriptor import TrackDescriptor +from ffx.media_descriptor import MediaDescriptor + +from .basename_combinator import BasenameCombinator + +from .indicator_combinator import IndicatorCombinator + + +class BasenameCombinator1(BasenameCombinator): + + VARIANT = 'B1' + + # def __init__(self, SubCombinators: dict = {}, context = None): + def __init__(self, context = None): + + self._context = context + self._logger = context['logger'] + self._reportLogger = context['report_logger'] + + # self._SubCombinators = SubCombinations + + def getVariant(self): + return BasenameCombinator1.VARIANT + + def getPayload(self): + return {'From': 'Encoders'} + + def assertFunc(self, mediaDescriptor: MediaDescriptor): + mediaTags = mediaDescriptor.getTags() + + assert 'From' in mediaTags.keys(), "'From' not in media tag keys" + assert mediaTags.keys()['From'] == 'Encoders', "Media tag value not 'Encoders' for key 'To'" + + def shouldFail(self): + return False + + def getYield(self): + + for MTC in MediaTagCombinator.getAllClassReferences(): + for DC2_A in DispositionCombinator2.getAllClassReferences(): + for TC2_A in TrackTagCombinator2.getAllClassReferences(): + for DC3_S in DispositionCombinator3.getAllClassReferences(): + for TC3_S in TrackTagCombinator3.getAllClassReferences(): + for J in JellyfinCombinator.getAllClassReferences(): + + j = J(self._context) + self._context['use_jellyfin'] = j.getPayload() + + dc2a = DC2_A(self._context) + tc2a = TC2_A(self._context) + dc3s = DC3_S(self._context) + tc3s = TC3_S(self._context) + mtc = MTC(self._context) + + yieldObj = {} + + yieldObj['identifier'] = self.getIdentifier() + yieldObj['variants'] = [self.getVariant(), + f"A:{dc2a.getVariant()}", + f"A:{tc2a.getVariant()}", + f"S:{dc3s.getVariant()}", + f"S:{tc3s.getVariant()}", + mtc.getVariant(), + j.getVariant()] + + yieldObj['payload'] = self.getPayload(dc2a.getPayload(), tc2a.getPayload(), dc3s.getPayload(), tc3s.getPayload()) + + yieldObj['assertSelectors'] = ['M', 'AD', 'AT', 'SD', 'ST', 'MT', 'J'] + + yieldObj['assertFuncs'] = [self.assertFunc, + dc2a.assertFunc, + tc2a.assertFunc, + dc3s.assertFunc, + tc3s.assertFunc, + mtc.assertFunc, + j.assertFunc] + + yieldObj['shouldFail'] = (self.shouldFail() + | dc2a.shouldFail() + | tc2a.shouldFail() + | dc3s.shouldFail() + | tc3s.shouldFail() + | mtc.shouldFail() + | j.shouldFail()) + + yield yieldObj diff --git a/bin/ffx/test/basename_combinator_2.py b/bin/ffx/test/basename_combinator_2.py new file mode 100644 index 0000000..7c4e0ce --- /dev/null +++ b/bin/ffx/test/basename_combinator_2.py @@ -0,0 +1,92 @@ +import os, sys, importlib, glob, inspect, itertools + +from ffx.track_type import TrackType + +from ffx.track_descriptor import TrackDescriptor +from ffx.media_descriptor import MediaDescriptor + +from .basename_combinator import BasenameCombinator + +from .indicator_combinator import IndicatorCombinator +from .label_combinator import LabelCombinator + +class BasenameCombinator2(BasenameCombinator): + + 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'] + + def getVariant(self): + return BasenameCombinator2.VARIANT + + def getPayload(self): + return {'To': 'Fanz', + 'Yolo': 'Holo'} + + def assertFunc(self, mediaDescriptor: MediaDescriptor): + mediaTags = mediaDescriptor.getTags() + + assert 'To' in mediaTags.keys(), "'To' not in media tag keys" + assert mediaTags.keys()['To'] == 'Fanz', "Media tag value not 'Fanz' for key 'To'" + assert 'Yolo' in mediaTags.keys(), "'Yolo' not in media tag keys" + assert mediaTags.keys()['Yolo'] == 'Holo', "Media tag value not 'Holo' for key 'Yolo'" + + def shouldFail(self): + return False + + def getYield(self): + + for L in LabelCombinator.getAllClassReferences(): + for I in IndicatorCombinator.getAllClassReferences(): + + for TC2_A in TrackTagCombinator2.getAllClassReferences(): + for DC3_S in DispositionCombinator3.getAllClassReferences(): + for TC3_S in TrackTagCombinator3.getAllClassReferences(): + for J in JellyfinCombinator.getAllClassReferences(): + + j = J(self._context) + self._context['use_jellyfin'] = j.getPayload() + + dc2a = DC2_A(self._context) + tc2a = TC2_A(self._context) + dc3s = DC3_S(self._context) + tc3s = TC3_S(self._context) + mtc = MTC(self._context) + + yieldObj = {} + + yieldObj['identifier'] = self.getIdentifier() + yieldObj['variants'] = [self.getVariant(), + f"A:{dc2a.getVariant()}", + f"A:{tc2a.getVariant()}", + f"S:{dc3s.getVariant()}", + f"S:{tc3s.getVariant()}", + mtc.getVariant(), + j.getVariant()] + + yieldObj['payload'] = self.getPayload(dc2a.getPayload(), tc2a.getPayload(), dc3s.getPayload(), tc3s.getPayload()) + + yieldObj['assertSelectors'] = ['M', 'AD', 'AT', 'SD', 'ST', 'MT', 'J'] + + yieldObj['assertFuncs'] = [self.assertFunc, + dc2a.assertFunc, + tc2a.assertFunc, + dc3s.assertFunc, + tc3s.assertFunc, + mtc.assertFunc, + j.assertFunc] + + yieldObj['shouldFail'] = (self.shouldFail() + | dc2a.shouldFail() + | tc2a.shouldFail() + | dc3s.shouldFail() + | tc3s.shouldFail() + | mtc.shouldFail() + | j.shouldFail()) + + yield yieldObj diff --git a/bin/ffx/test/indicator_combinator.py b/bin/ffx/test/indicator_combinator.py new file mode 100644 index 0000000..35f7ca9 --- /dev/null +++ b/bin/ffx/test/indicator_combinator.py @@ -0,0 +1,26 @@ +class IndicatorCombinator(): + + IDENTIFIER = 'indicator' + + MAX_SEASON = 3 + MAX_EPISODE = 3 + + def __init__(self, context = None): + self._context = context + self._logger = context['logger'] + self._reportLogger = context['report_logger'] + + def getIdentifier(self): + return IndicatorCombinator.IDENTIFIER + + def assertFunc(self, testObj = {}): + pass + + def shouldFail(self): + return False + + def getYield(self): + + for season in range(IndicatorCombinator.MAX_SEASON): + for episode in range(IndicatorCombinator.MAX_EPISODE): + yield f"S{season+1:02d}E{episode+1:02d}" diff --git a/bin/ffx/test/label_combinator.py b/bin/ffx/test/label_combinator.py new file mode 100644 index 0000000..dd3732d --- /dev/null +++ b/bin/ffx/test/label_combinator.py @@ -0,0 +1,36 @@ +import os, sys, importlib, glob, inspect, itertools + +class LabelCombinator(): + + IDENTIFIER = 'label' + PREFIX = 'label_combinator_' + + LABEL = 'media' + + def __init__(self, context = None): + self._context = context + self._logger = context['logger'] + self._reportLogger = context['report_logger'] + + def getIdentifier(self): + return LabelCombinator.IDENTIFIER + + @staticmethod + def list(): + basePath = os.path.dirname(__file__) + return [os.path.basename(p)[len(LabelCombinator.PREFIX):-3] + for p + in glob.glob(f"{ basePath }/{LabelCombinator.PREFIX}*.py", recursive = True) + if p != __file__] + + @staticmethod + def getClassReference(identifier): + importlib.import_module(f"ffx.test.{LabelCombinator.PREFIX}{ identifier }") + for name, obj in inspect.getmembers(sys.modules[f"ffx.test.{LabelCombinator.PREFIX}{ identifier }"]): + #HINT: Excluding MediaCombinator as it seems to be included by import (?) + if inspect.isclass(obj) and name != 'LabelCombinator' and name.startswith('LabelCombinator'): + return obj + + @staticmethod + def getAllClassReferences(): + return [LabelCombinator.getClassReference(i) for i in LabelCombinator.list()] diff --git a/bin/ffx/test/label_combinator_0.py b/bin/ffx/test/label_combinator_0.py new file mode 100644 index 0000000..3f40367 --- /dev/null +++ b/bin/ffx/test/label_combinator_0.py @@ -0,0 +1,30 @@ +import os, sys, importlib, glob, inspect, itertools + +from ffx.track_type import TrackType + +from ffx.track_descriptor import TrackDescriptor +from ffx.media_descriptor import MediaDescriptor + +from .label_combinator import LabelCombinator + + +class LabelCombinator0(LabelCombinator): + + VARIANT = 'L0' + + def __init__(self, context = None): + self._context = context + self._logger = context['logger'] + self._reportLogger = context['report_logger'] + + def getVariant(self): + return LabelCombinator0.VARIANT + + def getPayload(self): + return '' + + def assertFunc(self, testObj = {}): + pass + + def shouldFail(self): + return False diff --git a/bin/ffx/test/label_combinator_1.py b/bin/ffx/test/label_combinator_1.py new file mode 100644 index 0000000..50d0295 --- /dev/null +++ b/bin/ffx/test/label_combinator_1.py @@ -0,0 +1,30 @@ +import os, sys, importlib, glob, inspect, itertools + +from ffx.track_type import TrackType + +from ffx.track_descriptor import TrackDescriptor +from ffx.media_descriptor import MediaDescriptor + +from .label_combinator import LabelCombinator + +class LabelCombinator1(LabelCombinator): + + VARIANT = 'L1' + + def __init__(self, context = None): + + self._context = context + self._logger = context['logger'] + self._reportLogger = context['report_logger'] + + def getVariant(self): + return LabelCombinator1.VARIANT + + def getPayload(self): + return LabelCombinator.LABEL + + def assertFunc(self, testObj = {}): + pass + + def shouldFail(self): + return False diff --git a/bin/ffx/test/site_combinator.py b/bin/ffx/test/site_combinator.py new file mode 100644 index 0000000..9c83a10 --- /dev/null +++ b/bin/ffx/test/site_combinator.py @@ -0,0 +1,34 @@ +class SiteCombinator(): + + IDENTIFIER = 'site' + + SITE_LIST = [ + ".GerEngSub.AAC.1080pINDICATOR.WebDL.x264-Tanuki", + ".German.AC3.DL.1080pINDICATOR.BluRay.x264-AST4u", + "-720pINDICATOR" + ] + + def __init__(self, context = None, indicator = ''): + self._context = context + self._logger = context['logger'] + self._reportLogger = context['report_logger'] + + self.__indicator = indicator + + def getIdentifier(self): + return SiteCombinator.IDENTIFIER + + def getPayload(self, index): + site = SiteCombinator.SITE_LIST[index] + return site.replace('INDICATOR', f".{self.__indicator}") if self.__indicator else site.replace('INDICATOR', '') + + def assertFunc(self, testObj = {}): + pass + + def shouldFail(self): + return False + + def getYield(self): + + for titleIndex in len(SiteCombinator.SITE_LIST): + yield self.getPayload(titleIndex) diff --git a/bin/ffx/test/title_combinator.py b/bin/ffx/test/title_combinator.py new file mode 100644 index 0000000..002da0c --- /dev/null +++ b/bin/ffx/test/title_combinator.py @@ -0,0 +1,28 @@ +class TitleCombinator(): + + IDENTIFIER = 'title' + + TITLE_LIST = [ + 'The Sound of Space', + ' 2001: Odyssee im Weltraum (1968)', + 'Ansible 101' + ] + + def __init__(self, context = None): + self._context = context + self._logger = context['logger'] + self._reportLogger = context['report_logger'] + + def getIdentifier(self): + return TitleCombinator.IDENTIFIER + + def assertFunc(self, testObj = {}): + pass + + def shouldFail(self): + return False + + def getYield(self): + + for title in TitleCombinator.TITLE_LIST: + yield title