mirror of
https://github.com/gryf/pygtktalog.git
synced 2025-12-17 19:40:21 +01:00
Moved test module into root catalog of the project.
This commit is contained in:
0
test/__init__.py
Normal file
0
test/__init__.py
Normal file
45
test/run_tests.py
Executable file
45
test/run_tests.py
Executable file
@@ -0,0 +1,45 @@
|
||||
"""
|
||||
Project: pyGTKtalog
|
||||
Description: Test harvester and runner.
|
||||
Type: exec
|
||||
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
|
||||
Created: 2008-12-15
|
||||
"""
|
||||
import sys
|
||||
import unittest
|
||||
from os import path, chdir
|
||||
import glob
|
||||
|
||||
|
||||
def setup_path():
|
||||
"""Sets up the python include paths to include needed directories"""
|
||||
this_path = path.abspath(path.dirname(__file__))
|
||||
sys.path = [path.join(this_path, "unit")] + sys.path
|
||||
return
|
||||
|
||||
def build_suite():
|
||||
"""Build suite test from files in unit directory. Filenames with test
|
||||
suites should always end with "_test.py".
|
||||
"""
|
||||
modules = []
|
||||
for fname in glob.glob1('unit', '*_test.py'):
|
||||
class_name = fname[:-8]
|
||||
if "_" in class_name:
|
||||
splited = class_name.split("_")
|
||||
class_name = 'Test'
|
||||
for word in splited:
|
||||
class_name += word.capitalize()
|
||||
else:
|
||||
class_name = "Test" + class_name.capitalize()
|
||||
|
||||
modules.append(fname[:-3])
|
||||
|
||||
modules = map(__import__, modules)
|
||||
load = unittest.defaultTestLoader.loadTestsFromModule
|
||||
return unittest.TestSuite(map(load, modules))
|
||||
|
||||
if __name__ == "__main__":
|
||||
chdir(path.abspath(path.dirname(__file__)))
|
||||
setup_path()
|
||||
unittest.main(defaultTest="build_suite")
|
||||
|
||||
0
test/unit/__init__.py
Normal file
0
test/unit/__init__.py
Normal file
17
test/unit/dummy_test.py
Normal file
17
test/unit/dummy_test.py
Normal file
@@ -0,0 +1,17 @@
|
||||
"""
|
||||
Project: pyGTKtalog
|
||||
Description: This is simple dummy test for... testing purposes :)
|
||||
Type: test
|
||||
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
|
||||
Created: 2008-12-15
|
||||
"""
|
||||
import unittest
|
||||
|
||||
class TestDummy(unittest.TestCase):
|
||||
"""Fake test class"""
|
||||
def test_dummy_method(self):
|
||||
"""Test simple assertion"""
|
||||
self.assertTrue(True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
17
test/unit/foo_bar_test.py
Normal file
17
test/unit/foo_bar_test.py
Normal file
@@ -0,0 +1,17 @@
|
||||
"""
|
||||
Project: pyGTKtalog
|
||||
Description: This is another dummy test.
|
||||
Type: test
|
||||
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
|
||||
Created: 2008-12-15
|
||||
"""
|
||||
import unittest
|
||||
|
||||
class TestFooBar(unittest.TestCase):
|
||||
"""Fake test class"""
|
||||
def test_dummy_method(self):
|
||||
"""Test simple assertion"""
|
||||
self.assertTrue(True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
107
test/unit/video_test.py
Normal file
107
test/unit/video_test.py
Normal file
@@ -0,0 +1,107 @@
|
||||
"""
|
||||
Project: pyGTKtalog
|
||||
Description: Tests for Video class.
|
||||
Type: test
|
||||
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
|
||||
Created: 2008-12-15
|
||||
"""
|
||||
import unittest
|
||||
import os
|
||||
from pygtktalog.video import Video
|
||||
|
||||
class TestVideo(unittest.TestCase):
|
||||
"""Class for retrive midentify script output and put it in dict.
|
||||
Usually there is no need for such a detailed movie/clip information.
|
||||
Video script belongs to mplayer package.
|
||||
"""
|
||||
|
||||
def test_avi(self):
|
||||
"""test mock avi file, should return dict with expected values"""
|
||||
avi = Video("mocks/m.avi")
|
||||
self.assertTrue(len(avi.tags) != 0, "result should have lenght > 0")
|
||||
self.assertEqual(avi.tags['audio_format'], '85')
|
||||
self.assertEqual(avi.tags['width'], 128)
|
||||
self.assertEqual(avi.tags['audio_no_channels'], 2)
|
||||
self.assertEqual(avi.tags['height'], 96)
|
||||
self.assertEqual(avi.tags['video_format'], 'XVID')
|
||||
self.assertEqual(avi.tags['length'], 4)
|
||||
self.assertEqual(avi.tags['audio_codec'], 'mp3')
|
||||
self.assertEqual(avi.tags['video_codec'], 'ffodivx')
|
||||
self.assertEqual(avi.tags['duration'], '00:00:04')
|
||||
self.assertEqual(avi.tags['container'], 'avi')
|
||||
|
||||
def test_avi2(self):
|
||||
"""test another mock avi file, should return dict with expected
|
||||
values"""
|
||||
avi = Video("mocks/m1.avi")
|
||||
self.assertTrue(len(avi.tags) != 0, "result should have lenght > 0")
|
||||
self.assertEqual(avi.tags['audio_format'], '85')
|
||||
self.assertEqual(avi.tags['width'], 128)
|
||||
self.assertEqual(avi.tags['audio_no_channels'], 2)
|
||||
self.assertEqual(avi.tags['height'], 96)
|
||||
self.assertEqual(avi.tags['video_format'], 'H264')
|
||||
self.assertEqual(avi.tags['length'], 4)
|
||||
self.assertEqual(avi.tags['audio_codec'], 'mp3')
|
||||
self.assertEqual(avi.tags['video_codec'], 'ffh264')
|
||||
self.assertEqual(avi.tags['duration'], '00:00:04')
|
||||
self.assertEqual(avi.tags['container'], 'avi')
|
||||
|
||||
def test_mkv(self):
|
||||
"""test mock mkv file, should return dict with expected values"""
|
||||
avi = Video("mocks/m.mkv")
|
||||
self.assertTrue(len(avi.tags) != 0, "result should have lenght > 0")
|
||||
self.assertEqual(avi.tags['audio_format'], '8192')
|
||||
self.assertEqual(avi.tags['width'], 128)
|
||||
self.assertEqual(avi.tags['audio_no_channels'], 2)
|
||||
self.assertEqual(avi.tags['height'], 96)
|
||||
self.assertEqual(avi.tags['video_format'], 'mp4v')
|
||||
self.assertEqual(avi.tags['length'], 4)
|
||||
self.assertEqual(avi.tags['audio_codec'], 'a52')
|
||||
self.assertEqual(avi.tags['video_codec'], 'ffodivx')
|
||||
self.assertEqual(avi.tags['duration'], '00:00:04')
|
||||
self.assertEqual(avi.tags['container'], 'mkv')
|
||||
|
||||
def test_mpg(self):
|
||||
"""test mock mpg file, should return dict with expected values"""
|
||||
avi = Video("mocks/m.mpg")
|
||||
self.assertTrue(len(avi.tags) != 0, "result should have lenght > 0")
|
||||
self.assertFalse(avi.tags.has_key('audio_format'))
|
||||
self.assertEqual(avi.tags['width'], 128)
|
||||
self.assertFalse(avi.tags.has_key('audio_no_channels'))
|
||||
self.assertEqual(avi.tags['height'], 96)
|
||||
self.assertEqual(avi.tags['video_format'], '0x10000001')
|
||||
self.assertFalse(avi.tags.has_key('lenght'))
|
||||
self.assertFalse(avi.tags.has_key('audio_codec'))
|
||||
self.assertEqual(avi.tags['video_codec'], 'ffmpeg1')
|
||||
self.assertFalse(avi.tags.has_key('duration'))
|
||||
self.assertEqual(avi.tags['container'], 'mpeges')
|
||||
|
||||
def test_ogm(self):
|
||||
"""test mock ogm file, should return dict with expected values"""
|
||||
avi = Video("mocks/m.ogm")
|
||||
self.assertTrue(len(avi.tags) != 0, "result should have lenght > 0")
|
||||
self.assertEqual(avi.tags['audio_format'], '8192')
|
||||
self.assertEqual(avi.tags['width'], 160)
|
||||
self.assertEqual(avi.tags['audio_no_channels'], 2)
|
||||
self.assertEqual(avi.tags['height'], 120)
|
||||
self.assertEqual(avi.tags['video_format'], 'H264')
|
||||
self.assertEqual(avi.tags['length'], 4)
|
||||
self.assertEqual(avi.tags['audio_codec'], 'a52')
|
||||
self.assertEqual(avi.tags['video_codec'], 'ffh264')
|
||||
self.assertEqual(avi.tags['duration'], '00:00:04')
|
||||
self.assertEqual(avi.tags['container'], 'ogg')
|
||||
|
||||
def test_capture(self):
|
||||
"""test capture with some small movie"""
|
||||
avi = Video("mocks/m.avi")
|
||||
filename = avi.capture()
|
||||
self.assertTrue(filename != None)
|
||||
self.assertTrue(os.path.exists(filename))
|
||||
file_size = os.stat(filename)[6]
|
||||
self.assertEqual(file_size, 9077)
|
||||
os.unlink(filename)
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.join(os.path.abspath(os.path.dirname(__file__)), "../"))
|
||||
print os.path.abspath(os.path.curdir)
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user