Scenaro 1 Tests passed
parent
207472283b
commit
de0f4a57c1
@ -1,12 +1,151 @@
|
|||||||
|
import os, sys, click
|
||||||
|
|
||||||
from .scenario import Scenario
|
from .scenario import Scenario
|
||||||
|
|
||||||
|
from ffx.test.helper import createMediaTestFile
|
||||||
|
from ffx.process import executeProcess
|
||||||
|
|
||||||
|
from ffx.file_properties import FileProperties
|
||||||
|
|
||||||
|
from ffx.media_descriptor import MediaDescriptor
|
||||||
|
from ffx.track_descriptor import TrackDescriptor
|
||||||
|
|
||||||
|
from ffx.track_type import TrackType
|
||||||
|
from ffx.track_disposition import TrackDisposition
|
||||||
|
|
||||||
|
from ffx.test.media_combinator import MediaCombinator
|
||||||
|
|
||||||
|
|
||||||
class Scenario2(Scenario):
|
class Scenario2(Scenario):
|
||||||
|
"""Creating file VAa, h264/aac/aac
|
||||||
|
Converting to VaA, vp9/opus/opus
|
||||||
|
No tmdb, default parameters"""
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
|
|
||||||
|
context['use_jellyfin'] = True
|
||||||
|
context['use_tmdb'] = False
|
||||||
|
context['use_pattern'] = False
|
||||||
|
#context['no_prompt'] = False
|
||||||
|
|
||||||
super().__init__(context)
|
super().__init__(context)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# def job(self, yieldObj: dict):
|
||||||
|
#
|
||||||
|
# testContext = self._context.copy()
|
||||||
|
#
|
||||||
|
# identifier = yieldObj['identifier']
|
||||||
|
# variantList = yieldObj['variants']
|
||||||
|
#
|
||||||
|
# variantIdentifier = '-'.join(variantList)
|
||||||
|
# variantLabel = f"{self.__class__.__name__} Variant {variantIdentifier}"
|
||||||
|
#
|
||||||
|
# sourceMediaDescriptor: MediaDescriptor = yieldObj['payload']
|
||||||
|
# assertSelectorList: list = yieldObj['assertSelectors']
|
||||||
|
# assertFuncList = yieldObj['assertFuncs']
|
||||||
|
# shouldFail = yieldObj['shouldFail']
|
||||||
|
#
|
||||||
|
# try:
|
||||||
|
# jellyfinSelectorIndex = assertSelectorList.index('J')
|
||||||
|
# jellyfinVariant = variantList[jellyfinSelectorIndex]
|
||||||
|
# testContext['use_jellyfin'] = jellyfinVariant == 'J1'
|
||||||
|
# except ValueError:
|
||||||
|
# jellyfinSelectorIndex = -1
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# if self._context['test_variant'] and variantIdentifier != self._context['test_variant']:
|
||||||
|
# return
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# self._logger.debug(f"Running Job: {variantLabel}")
|
||||||
|
#
|
||||||
|
# # Phase 1: Setup source files
|
||||||
|
# self.clearTestDirectory()
|
||||||
|
# mediaFilePath = createMediaTestFile(mediaDescriptor=sourceMediaDescriptor, directory=self._testDirectory, logger=self._logger, length = 2)
|
||||||
|
#
|
||||||
|
# # # Phase 2: Prepare database
|
||||||
|
# #
|
||||||
|
# # Phase 3: Run ffx
|
||||||
|
# commandSequence = [sys.executable,
|
||||||
|
# self._ffxExecutablePath,
|
||||||
|
# 'convert',
|
||||||
|
# mediaFilePath,
|
||||||
|
# '--no-prompt']
|
||||||
|
#
|
||||||
|
# if not testContext['use_jellyfin']:
|
||||||
|
# commandSequence += ['--no-jellyfin']
|
||||||
|
#
|
||||||
|
# self._logger.debug(f"{variantLabel}: Test sequence: {commandSequence}")
|
||||||
|
#
|
||||||
|
# out, err, rc = executeProcess(commandSequence, directory = self._testDirectory)
|
||||||
|
#
|
||||||
|
# if out:
|
||||||
|
# self._logger.debug(f"{variantLabel}: Process output: {out}")
|
||||||
|
# if rc:
|
||||||
|
# self._logger.debug(f"{variantLabel}: Process returned ERROR {rc} ({err})")
|
||||||
|
#
|
||||||
|
# # Phase 4: Evaluate results
|
||||||
|
#
|
||||||
|
# try:
|
||||||
|
#
|
||||||
|
# jobFailed = bool(rc)
|
||||||
|
#
|
||||||
|
# self._logger.debug(f"{variantLabel}: Should fail: {shouldFail} / actually failed: {jobFailed}")
|
||||||
|
#
|
||||||
|
# assert jobFailed == shouldFail, f"Process {'failed' if jobFailed else 'did not fail'}"
|
||||||
|
#
|
||||||
|
# if not jobFailed:
|
||||||
|
#
|
||||||
|
# resultFile = os.path.join(self._testDirectory, 'media.webm')
|
||||||
|
#
|
||||||
|
# assert os.path.isfile(resultFile), f"Result file 'media.webm' in path '{self._testDirectory}' wasn't created"
|
||||||
|
#
|
||||||
|
# resultFileProperties = FileProperties(testContext, resultFile)
|
||||||
|
# resultMediaDescriptor = resultFileProperties.getMediaDescriptor()
|
||||||
|
#
|
||||||
|
# if testContext['use_jellyfin']:
|
||||||
|
# sourceMediaDescriptor.applyJellyfinOrder()
|
||||||
|
# resultMediaDescriptor.applySourceIndices(sourceMediaDescriptor)
|
||||||
|
#
|
||||||
|
# resultMediaTracks = resultMediaDescriptor.getAllTrackDescriptors()
|
||||||
|
#
|
||||||
|
# for assertIndex in range(len(assertSelectorList)):
|
||||||
|
#
|
||||||
|
# assertSelector = assertSelectorList[assertIndex]
|
||||||
|
# assertFunc = assertFuncList[assertIndex]
|
||||||
|
# assertVariant = variantList[assertIndex]
|
||||||
|
#
|
||||||
|
# if assertSelector == 'M':
|
||||||
|
# assertFunc()
|
||||||
|
# for variantIndex in range(len(assertVariant)):
|
||||||
|
# assert assertVariant[variantIndex].lower() == resultMediaTracks[variantIndex].getType().indicator(), f"Stream #{variantIndex} is not of type {resultMediaTracks[variantIndex].getType().label()}"
|
||||||
|
#
|
||||||
|
# elif assertSelector == 'AD' or assertSelector == 'AT':
|
||||||
|
# assertFunc(resultMediaDescriptor.getAudioTracks())
|
||||||
|
#
|
||||||
|
# elif assertSelector == 'SD' or assertSelector == 'ST':
|
||||||
|
# assertFunc(resultMediaDescriptor.getSubtitleTracks())
|
||||||
|
#
|
||||||
|
# elif type(assertSelector) is str:
|
||||||
|
# if assertSelector == 'J':
|
||||||
|
# assertFunc()
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# self._reportLogger.info(f"{variantLabel}: Test passed")
|
||||||
|
#
|
||||||
|
# except AssertionError as ae:
|
||||||
|
#
|
||||||
|
# self._reportLogger.error(f"{variantLabel}: Test FAILED ({ae})")
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
pass
|
||||||
# self._testDirectory
|
|
||||||
|
|
||||||
#createMediaTestFile()
|
# MC_list = MediaCombinator.getAllClassReferences()
|
||||||
|
# for MC in MC_list:
|
||||||
|
# self._logger.debug(f"MC={MC.__name__}")
|
||||||
|
# mc = MC(context = self._context)
|
||||||
|
# for y in mc.getYield():
|
||||||
|
# self.job(y)
|
||||||
|
Loading…
Reference in New Issue