1
0
mirror of https://github.com/gryf/pygtktalog.git synced 2026-04-24 23:31:24 +02:00

changes in tests, upgrade to new EXIF module, etc

This commit is contained in:
2009-04-07 19:40:15 +00:00
parent fb920f58bc
commit 5e8c33f05a
14 changed files with 1241 additions and 741 deletions
+9 -36
View File
@@ -1,53 +1,27 @@
#!/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
# -------------------------------------------------------------------------
"""
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 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"""
"""Build suite test from files in unit directory. Filenames with test
suites should always end with "_test.py"."""
modules = []
classes = []
for fname in glob.glob1('unit', '*_test.py'):
class_name = fname[:-8]
if "_" in class_name:
@@ -59,7 +33,6 @@ def build_suite():
class_name = "Test" + class_name.capitalize()
modules.append(fname[:-3])
classes.append(class_name)
modules = map(__import__, modules)
load = unittest.defaultTestLoader.loadTestsFromModule
+8 -2
View File
@@ -1,9 +1,15 @@
# This Python file uses the following encoding: utf-8
"""
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_dummyMethod(self):
def test_dummy_method(self):
"""Test simple assertion"""
self.assertTrue(True)
+8 -2
View File
@@ -1,9 +1,15 @@
# This Python file uses the following encoding: utf-8
"""
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_dummyMethod(self):
def test_dummy_method(self):
"""Test simple assertion"""
self.assertTrue(True)
+31 -25
View File
@@ -1,4 +1,10 @@
# This Python file uses the following encoding: utf-8
"""
Project: pyGTKtalog
Description: Tests for Midentify class.
Type: test
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2008-12-15
"""
import unittest
from lib.midentify import Midentify
@@ -8,82 +14,82 @@ class TestMidentify(unittest.TestCase):
Midentify script belongs to mplayer package.
"""
def test_testAvi(self):
def test_avi(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['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['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):
def test_avi2(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['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['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):
def test_mkv(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['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['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):
def test_mpg(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.assertEqual(result_dict['width'], 128)
self.assertFalse(result_dict.has_key('audio_no_channels'))
self.assertEqual(result_dict['height'], '96')
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.assertEqual(result_dict['video_codec'], 'ffmpeg1')
self.assertFalse(result_dict.has_key('duration'))
self.assertEqual(result_dict['container'], 'mpeges')
def test_testOgm(self):
def test_ogm(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['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['length'], 4)
self.assertEqual(result_dict['audio_codec'], 'a52')
self.assertEqual(result_dict['video_codec'], 'ffh264')
self.assertEqual(result_dict['duration'], '00:00:04')