mirror of
https://github.com/gryf/pygtktalog.git
synced 2026-04-24 15:11:25 +02:00
* Added shell script for preparing distfile.
* Added unitests. * Added mocks for video files. * Added midentify module.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable
+76
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env python
|
||||
# This Python file uses the following encoding: utf-8
|
||||
#
|
||||
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
|
||||
#
|
||||
# Copyright (C) 2007 by Roman 'gryf' Dobosz
|
||||
#
|
||||
# This file is part of pyGTKtalog.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
import sys
|
||||
import unittest
|
||||
from os import path, chdir
|
||||
import glob
|
||||
|
||||
|
||||
def my_import(module, name):
|
||||
"""import replacement"""
|
||||
mod = __import__(module, {}, {}, [name])
|
||||
components = name.split('.')
|
||||
for comp in components[1:]:
|
||||
mod = getattr(mod, comp)
|
||||
return mod
|
||||
|
||||
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, "../../src")] + sys.path
|
||||
sys.path = [path.join(this_path, "../../src/test")] + sys.path
|
||||
sys.path = [path.join(this_path, "../../src/test/unit")] + sys.path
|
||||
return
|
||||
|
||||
def build_suite():
|
||||
"""build suite test from files in unit directory"""
|
||||
modules = []
|
||||
classes = []
|
||||
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])
|
||||
classes.append(class_name)
|
||||
|
||||
modules = map(__import__, modules)
|
||||
#my_import(fname[:-3], class_name)
|
||||
load = unittest.defaultTestLoader.loadTestsFromModule
|
||||
return unittest.TestSuite(map(load, modules))
|
||||
|
||||
#exec('suite.addTest(TL().loadTestsFromTestCase('+class_name+'))')
|
||||
#return suite
|
||||
|
||||
if __name__ == "__main__":
|
||||
chdir(path.abspath(path.curdir))
|
||||
setup_path()
|
||||
unittest.main(defaultTest="build_suite")
|
||||
#unittest.TextTestRunner().run(build_suite())
|
||||
@@ -0,0 +1,11 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
import unittest
|
||||
|
||||
class TestDummy(unittest.TestCase):
|
||||
"""Fake test class"""
|
||||
def test_dummyMethod(self):
|
||||
"""Test simple assertion"""
|
||||
self.assertTrue(True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,11 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
import unittest
|
||||
|
||||
class TestFooBar(unittest.TestCase):
|
||||
"""Fake test class"""
|
||||
def test_dummyMethod(self):
|
||||
"""Test simple assertion"""
|
||||
self.assertTrue(True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,93 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
import unittest
|
||||
from lib.midentify import Midentify
|
||||
|
||||
class TestMidentify(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.
|
||||
Midentify script belongs to mplayer package.
|
||||
"""
|
||||
|
||||
def test_testAvi(self):
|
||||
"""test mock avi file, should return dict with expected values"""
|
||||
avi = Midentify("mocks/m.avi")
|
||||
result_dict = avi.get_data()
|
||||
self.assertTrue(len(result_dict) != 0, "result should have lenght > 0")
|
||||
self.assertEqual(result_dict['audio_format'], '85')
|
||||
self.assertEqual(result_dict['width'], '128')
|
||||
self.assertEqual(result_dict['audio_no_channels'], '2')
|
||||
self.assertEqual(result_dict['height'], '96')
|
||||
self.assertEqual(result_dict['video_format'], 'XVID')
|
||||
self.assertEqual(result_dict['length'], '4')
|
||||
self.assertEqual(result_dict['audio_codec'], 'mp3')
|
||||
self.assertEqual(result_dict['video_codec'], 'ffodivx')
|
||||
self.assertEqual(result_dict['duration'], '00:00:04')
|
||||
self.assertEqual(result_dict['container'], 'avi')
|
||||
|
||||
def test_testAvi2(self):
|
||||
"""test another mock avi file, should return dict with expected
|
||||
values"""
|
||||
avi = Midentify("mocks/m1.avi")
|
||||
result_dict = avi.get_data()
|
||||
self.assertTrue(len(result_dict) != 0, "result should have lenght > 0")
|
||||
self.assertEqual(result_dict['audio_format'], '85')
|
||||
self.assertEqual(result_dict['width'], '128')
|
||||
self.assertEqual(result_dict['audio_no_channels'], '2')
|
||||
self.assertEqual(result_dict['height'], '96')
|
||||
self.assertEqual(result_dict['video_format'], 'H264')
|
||||
self.assertEqual(result_dict['length'], '4')
|
||||
self.assertEqual(result_dict['audio_codec'], 'mp3')
|
||||
self.assertEqual(result_dict['video_codec'], 'ffh264')
|
||||
self.assertEqual(result_dict['duration'], '00:00:04')
|
||||
self.assertEqual(result_dict['container'], 'avi')
|
||||
|
||||
def test_testMkv(self):
|
||||
"""test mock mkv file, should return dict with expected values"""
|
||||
avi = Midentify("mocks/m.mkv")
|
||||
result_dict = avi.get_data()
|
||||
self.assertTrue(len(result_dict) != 0, "result should have lenght > 0")
|
||||
self.assertEqual(result_dict['audio_format'], '8192')
|
||||
self.assertEqual(result_dict['width'], '128')
|
||||
self.assertEqual(result_dict['audio_no_channels'], '2')
|
||||
self.assertEqual(result_dict['height'], '96')
|
||||
self.assertEqual(result_dict['video_format'], 'mp4v')
|
||||
self.assertEqual(result_dict['length'], '4')
|
||||
self.assertEqual(result_dict['audio_codec'], 'a52')
|
||||
self.assertEqual(result_dict['video_codec'], 'ffodivx')
|
||||
self.assertEqual(result_dict['duration'], '00:00:04')
|
||||
self.assertEqual(result_dict['container'], 'mkv')
|
||||
|
||||
def test_testMpg(self):
|
||||
"""test mock mpg file, should return dict with expected values"""
|
||||
avi = Midentify("mocks/m.mpg")
|
||||
result_dict = avi.get_data()
|
||||
self.assertTrue(len(result_dict) != 0, "result should have lenght > 0")
|
||||
self.assertFalse(result_dict.has_key('audio_format'))
|
||||
self.assertEqual(result_dict['width'], '128')
|
||||
self.assertFalse(result_dict.has_key('audio_no_channels'))
|
||||
self.assertEqual(result_dict['height'], '96')
|
||||
self.assertEqual(result_dict['video_format'], '0x10000001')
|
||||
self.assertFalse(result_dict.has_key('lenght'))
|
||||
self.assertFalse(result_dict.has_key('audio_codec'))
|
||||
self.assertEqual(result_dict['video_codec'], 'mpegpes')
|
||||
self.assertFalse(result_dict.has_key('duration'))
|
||||
self.assertEqual(result_dict['container'], 'mpeges')
|
||||
|
||||
def test_testOgm(self):
|
||||
"""test mock ogm file, should return dict with expected values"""
|
||||
avi = Midentify("mocks/m.ogm")
|
||||
result_dict = avi.get_data()
|
||||
self.assertTrue(len(result_dict) != 0, "result should have lenght > 0")
|
||||
self.assertEqual(result_dict['audio_format'], '8192')
|
||||
self.assertEqual(result_dict['width'], '160')
|
||||
self.assertEqual(result_dict['audio_no_channels'], '2')
|
||||
self.assertEqual(result_dict['height'], '120')
|
||||
self.assertEqual(result_dict['video_format'], 'H264')
|
||||
self.assertEqual(result_dict['length'], '4')
|
||||
self.assertEqual(result_dict['audio_codec'], 'a52')
|
||||
self.assertEqual(result_dict['video_codec'], 'ffh264')
|
||||
self.assertEqual(result_dict['duration'], '00:00:04')
|
||||
self.assertEqual(result_dict['container'], 'ogg')
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user