Adding tests; scenario 1 MWE
parent
772c1d8f90
commit
3647b25b4c
@ -1,9 +1,9 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
def executeProcess(commandSequence: List[str]):
|
def executeProcess(commandSequence: List[str], directory: str = None):
|
||||||
# process = subprocess.Popen([t.encode('utf-8') for t in commandSequence], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
# process = subprocess.Popen([t.encode('utf-8') for t in commandSequence], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
process = subprocess.Popen(commandSequence, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8')
|
process = subprocess.Popen(commandSequence, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8', cwd = directory)
|
||||||
output, error = process.communicate()
|
output, error = process.communicate()
|
||||||
# return output.decode('utf-8'), error.decode('utf-8'), process.returncode
|
# return output.decode('utf-8'), error.decode('utf-8'), process.returncode
|
||||||
return output, error, process.returncode
|
return output, error, process.returncode
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
import os, sys, click
|
|
||||||
|
|
||||||
from .scenario import Scenario
|
|
||||||
|
|
||||||
from ffx.test.helper import createMediaFile
|
|
||||||
from ffx.process import executeProcess
|
|
||||||
|
|
||||||
class Scenario1(Scenario):
|
|
||||||
"""Creating file VAa, h264/aac/aac
|
|
||||||
Converting to VaA, vp9/opus/opus
|
|
||||||
No tmdb, default parameters"""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def i_am(self):
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
|
|
||||||
click.echo(f"Running scenario 1")
|
|
||||||
|
|
||||||
mediaFilePath = createMediaFile(directory=self._testDirectory)
|
|
||||||
|
|
||||||
commandSequence = [sys.executable, os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'ffx.py'), '--help']
|
|
||||||
|
|
||||||
|
|
||||||
click.echo(f"Scenarion 1 test sequence: {commandSequence}")
|
|
||||||
|
|
||||||
out, err, rc = executeProcess(commandSequence)
|
|
||||||
click.echo(out)
|
|
@ -0,0 +1,92 @@
|
|||||||
|
import os, sys, click
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
class Scenario1(Scenario):
|
||||||
|
"""Creating file VAa, h264/aac/aac
|
||||||
|
Converting to VaA, vp9/opus/opus
|
||||||
|
No tmdb, default parameters"""
|
||||||
|
|
||||||
|
def __init__(self, context):
|
||||||
|
super().__init__(context)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
|
||||||
|
click.echo(f"Running scenario 1")
|
||||||
|
|
||||||
|
kwargs = {}
|
||||||
|
kwargs[TrackDescriptor.TRACK_TYPE_KEY] = TrackType.VIDEO
|
||||||
|
kwargs[TrackDescriptor.DISPOSITION_SET_KEY] = set([TrackDisposition.DEFAULT])
|
||||||
|
trackDescriptor1 = TrackDescriptor(**kwargs)
|
||||||
|
|
||||||
|
kwargs = {}
|
||||||
|
kwargs[TrackDescriptor.TRACK_TYPE_KEY] = TrackType.AUDIO
|
||||||
|
kwargs[TrackDescriptor.DISPOSITION_SET_KEY] = set([TrackDisposition.DEFAULT])
|
||||||
|
trackDescriptor2 = TrackDescriptor(**kwargs)
|
||||||
|
|
||||||
|
kwargs = {}
|
||||||
|
kwargs[TrackDescriptor.TRACK_TYPE_KEY] = TrackType.AUDIO
|
||||||
|
trackDescriptor3 = TrackDescriptor(**kwargs)
|
||||||
|
|
||||||
|
kwargs = {}
|
||||||
|
kwargs[MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY] = [trackDescriptor1,
|
||||||
|
trackDescriptor2,
|
||||||
|
trackDescriptor3]
|
||||||
|
sourceMediaDescriptor = MediaDescriptor(**kwargs)
|
||||||
|
sourceMediaDescriptor.reindexSubIndices()
|
||||||
|
|
||||||
|
# Phase 1: Setup source files
|
||||||
|
mediaFilePath = createMediaTestFile(mediaDescriptor=sourceMediaDescriptor, directory=self._testDirectory)
|
||||||
|
|
||||||
|
# Phase 2: Prepare database
|
||||||
|
|
||||||
|
# Phase 3: Run ffx
|
||||||
|
commandSequence = [sys.executable,
|
||||||
|
self._ffxExecutablePath,
|
||||||
|
'convert',
|
||||||
|
mediaFilePath]
|
||||||
|
|
||||||
|
click.echo(f"Scenarion 1 test sequence: {commandSequence}")
|
||||||
|
|
||||||
|
out, err, rc = executeProcess(commandSequence, directory = self._testDirectory)
|
||||||
|
click.echo(f"process output: {out}")
|
||||||
|
|
||||||
|
|
||||||
|
# Phase 4: Evaluate results
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
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(self._context, resultFile)
|
||||||
|
resultMediaDescriptor = resultFileProperties.getMediaDescriptor()
|
||||||
|
|
||||||
|
resultMediaTracks = resultMediaDescriptor.getAllTrackDescriptors()
|
||||||
|
|
||||||
|
assert len(resultMediaTracks) == 3, f"Result file contains unexpected number of streams"
|
||||||
|
|
||||||
|
assert resultMediaTracks[0].getType() == TrackType.VIDEO, f"Stream #0 is not of type video"
|
||||||
|
|
||||||
|
assert resultMediaTracks[1].getType() == TrackType.AUDIO, f"Stream #1 is not of type audio"
|
||||||
|
assert not resultMediaTracks[1].getDispositionFlag(TrackDisposition.DEFAULT), f"Stream #1 has set default disposition"
|
||||||
|
|
||||||
|
assert resultMediaTracks[2].getType() == TrackType.AUDIO, f"Stream #2 is not of type audio"
|
||||||
|
assert resultMediaTracks[2].getDispositionFlag(TrackDisposition.DEFAULT), f"Stream #1 has not set default disposition"
|
||||||
|
|
||||||
|
except AssertionError as ae:
|
||||||
|
|
||||||
|
click.echo(f"Scenario 1 test failed ({ae})")
|
Loading…
Reference in New Issue