Skip to content

Commit ffab1fc

Browse files
author
Clement Champetier
committed
pyTest: added test to check file properties as json
1 parent 6a63e4b commit ffab1fc

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

test/pyTest/testProperties.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
# Check if environment is setup to run the tests
44
if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None or \
5-
os.environ.get('AVTRANSCODER_TEST_VIDEO_MP4_FILE') is None:
5+
os.environ.get('AVTRANSCODER_TEST_AUDIO_MP4_FILE') is None or \
6+
os.environ.get('AVTRANSCODER_TEST_VIDEO_MOV_FILE') is None:
67
from nose.plugins.skip import SkipTest
78
raise SkipTest("Need to define environment variables "
89
"AVTRANSCODER_TEST_AUDIO_WAVE_FILE and "
9-
"AVTRANSCODER_TEST_VIDEO_MP4_FILE")
10+
"AVTRANSCODER_TEST_VIDEO_MP4_FILE and "
11+
"AVTRANSCODER_TEST_VIDEO_MOV_FILE")
1012

1113
from nose.tools import *
1214

@@ -38,6 +40,7 @@ def testAddMetadataDate():
3840

3941
assert_in( metadata_to_check, properties.getMetadatas() )
4042

43+
4144
def testAddImpossibleMetadata():
4245
"""
4346
Can't add an impossible metadata to the outputFile.
@@ -94,6 +97,7 @@ def testCheckVideoProperties():
9497
assert_equals( round(videoStream.getDuration(), 2), expectedDuration )
9598
assert_equals( videoStream.getFps(), expectedFps )
9699

100+
97101
def testCheckAudioProperties():
98102
"""
99103
Check properties of an audio stream.
@@ -122,4 +126,19 @@ def testCheckAudioProperties():
122126
assert_equals( round(audioStream.getDuration(), 2), expectedDuration )
123127
assert_equals( audioStream.getChannels(), expectedChannels )
124128
assert_equals( audioStream.getChannelLayout(), expectedChannelLayout )
125-
assert_equals( audioStream.getSampleRate(), expectedSampleRate )
129+
assert_equals( audioStream.getSampleRate(), expectedSampleRate )
130+
131+
132+
def testCheckFilePropertiesAsJson():
133+
"""
134+
Check file properties as json.
135+
"""
136+
# get src file
137+
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_MOV_FILE']
138+
inputFile = av.InputFile( inputFileName )
139+
140+
import json
141+
# throw exception if it is not a valid JSON
142+
json.loads(inputFile.getProperties().getPropertiesAsJson())
143+
144+

0 commit comments

Comments
 (0)