Skip to content

Commit ef30efd

Browse files
author
Clement Champetier
committed
pyTest: added tests to check util functions
1 parent 981e7c7 commit ef30efd

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

test/pyTest/testUtil.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
from nose.tools import *
2+
3+
from pyAvTranscoder import avtranscoder as av
4+
5+
6+
def testSupportedPixelFormats():
7+
"""
8+
Check supported pixel formats of mpeg2video codec.
9+
Check access to the list of all supported pixel formats.
10+
"""
11+
# Check supported pixel formats of mpeg2video codec
12+
videoCodecName = "mpeg2video"
13+
mpeg2videoSupportedPixelFormats = av.getSupportedPixelFormats(videoCodecName)
14+
assert_equals(len(mpeg2videoSupportedPixelFormats), 2)
15+
assert_in("yuv420p", mpeg2videoSupportedPixelFormats)
16+
assert_in("yuv422p", mpeg2videoSupportedPixelFormats)
17+
18+
# Check if there is more pixel formats available
19+
allSupportedPixelFormats = av.getSupportedPixelFormats()
20+
assert_less(len(mpeg2videoSupportedPixelFormats), len(allSupportedPixelFormats))
21+
22+
23+
def testSupportedSampleFormats():
24+
"""
25+
Check supported sample formats of pcm_s24le codec.
26+
Check access to the list of all supported sample formats.
27+
"""
28+
# Check supported sample formats of pcm_s24le codec
29+
audioCodecName = "pcm_s24le"
30+
pcmSupportedSampleFormats = av.getSupportedSampleFormats(audioCodecName)
31+
assert_equals(len(pcmSupportedSampleFormats), 1)
32+
assert_in("s32", pcmSupportedSampleFormats)
33+
34+
# Check if there is more sample formats available
35+
allSupportedSampleFormats = av.getSupportedSampleFormats()
36+
assert_less(len(pcmSupportedSampleFormats), len(allSupportedSampleFormats))
37+
38+
39+
def testAccessToAPixelFormat():
40+
"""
41+
Check if we can access an AVPixelFormat from a name, and retrieve the name from this constant value.
42+
"""
43+
strPixelFormat = "yuv420p"
44+
avPixelFormat = av.getAVPixelFormat(strPixelFormat)
45+
assert_equals(av.getPixelFormatName(avPixelFormat), strPixelFormat)
46+
47+
48+
def testAccessToASampleFormat():
49+
"""
50+
Check if we can access an AVSampleFormat from a name, and retrieve the name from this constant value.
51+
"""
52+
strSampleFormat = "s32"
53+
avSampleFormat = av.getAVSampleFormat(strSampleFormat)
54+
assert_equals(av.getSampleFormatName(avSampleFormat), strSampleFormat)
55+
56+
57+
def testAccessToAvailableFormatsNames():
58+
"""
59+
Check if we can access the list of available formats.
60+
@note Tested with ffmpeg-2.4.2
61+
"""
62+
availableFormats = av.getAvailableFormatsNames()
63+
assert_greater_equal(len(availableFormats), 135)
64+
65+
66+
def testAccessToAvailableVideoCodecsNames():
67+
"""
68+
Check if we can access the list of available video codecs.
69+
@note Tested with ffmpeg-2.4.2
70+
"""
71+
availableVideoCodecs = av.getAvailableVideoCodecsNames()
72+
assert_greater_equal(len(availableVideoCodecs), 204)
73+
74+
75+
def testAccessToAvailableAudioCodecsNames():
76+
"""
77+
Check if we can access the list of available audio codecs.
78+
@note Tested with ffmpeg-2.4.2
79+
"""
80+
availableAudioCodecs = av.getAvailableAudioCodecsNames()
81+
assert_greater_equal(len(availableAudioCodecs), 152)

0 commit comments

Comments
 (0)