conduit r1248 - in trunk: . test/python-tests test/python-tests/data



Author: jstowers
Date: Sat Jan 19 05:20:44 2008
New Revision: 1248
URL: http://svn.gnome.org/viewvc/conduit?rev=1248&view=rev

Log:
2008-01-19  John Stowers  <john stowers gmail com>

	* test/python-tests/common.py:
	* test/python-tests/data/audio.list:
	* test/python-tests/data/file.list:
	* test/python-tests/data/image.list:
	* test/python-tests/data/simple-1.vcard:
	* test/python-tests/data/video.list: Add mechanism for specifying resources
	that live on a local machine, and can be used as part of the test process.
	This means that we can use local media, etc as resources for testing AV
	conversion, and not have to get files from the web
	
	* test/python-tests/TestCoreConvertAudioVideo.py: Test AV conversion of
	the local resources, as defined above



Added:
   trunk/test/python-tests/TestCoreConvertAudioVideo.py
      - copied, changed from r1224, /trunk/test/python-tests/TestConvertAudioVideo.py
   trunk/test/python-tests/data/audio.list
   trunk/test/python-tests/data/file.list
   trunk/test/python-tests/data/image.list
   trunk/test/python-tests/data/video.list
Removed:
   trunk/test/python-tests/TestConvertAudioVideo.py
   trunk/test/python-tests/data/simple-1.vcard
Modified:
   trunk/ChangeLog
   trunk/test/python-tests/common.py

Copied: trunk/test/python-tests/TestCoreConvertAudioVideo.py (from r1224, /trunk/test/python-tests/TestConvertAudioVideo.py)
==============================================================================
--- /trunk/test/python-tests/TestConvertAudioVideo.py	(original)
+++ trunk/test/python-tests/TestCoreConvertAudioVideo.py	Sat Jan 19 05:20:44 2008
@@ -6,15 +6,7 @@
 import conduit.datatypes.Video as Video
 import conduit.datatypes.Audio as Audio
 import conduit.Utils as Utils
-import conduit.modules.AudioVideoConverterModule as AVModule
-
-FILES = (
-#uri                                                                        #conversion args
-("/home/john/Videos/photoriver.mov",                                        Video.PRESET_ENCODINGS['flv']),
-("/home/john/Videos/photoriver.mov",                                        Video.PRESET_ENCODINGS['divx']),
-("/home/john/Videos/photoriver.mov",                                        Video.PRESET_ENCODINGS['ogg']),
-("/home/john/Music/01 - Problems.mp3",                                      Audio.PRESET_ENCODINGS['ogg'])
-)
+import conduit.Exceptions as Exceptions
 
 test = SimpleTest()
 tc = test.type_converter
@@ -22,18 +14,26 @@
 ok("Video Conversion exists", tc.conversion_exists("file","file/video") == True)
 ok("Audio Conversion exists", tc.conversion_exists("file","file/audio") == True)
 
-for uri, args in FILES:
-    f = File.File(uri)
-    if f.exists():
-        mimeType = f.get_mimetype()
-        if mimeType.startswith("video/") or mimeType.startswith("audio/"):
-            to_type = "file/%s?%s" % (mimeType.split("/")[0],Utils.encode_conversion_args(args))
+TEST = (
+#name.list          #encodings to test  #available encodings
+("video",           ('divx',),          Video.PRESET_ENCODINGS      ),
+("audio",           ('ogg',),           Audio.PRESET_ENCODINGS      ),
+)
+
+for name, test_encodings, all_encodings in TEST:
+    files = get_external_resources(name)
+    for description,uri in files.items():
+        f = File.File(uri)
+        ok("%s: File %s exists" % (name,uri), f.exists())
+        for encoding in test_encodings:
+            args = all_encodings[encoding]
+            ok("%s: Testing encoding of %s -> %s" % (name,description,encoding), True)
+            to_type = "file/%s?%s" % (name,Utils.encode_conversion_args(args))
             try:
                 newdata = tc.convert("file",to_type, f)
-                ok("Conversion -> %s%s" % f.get_filename_and_extension(), newdata != None and newdata.exists())
-            except Exception:
-                traceback.print_exc()
-                ok("Conversion failed", False)
+                ok("%s: Conversion OK" % name, newdata != None and newdata.exists(), False)
+            except Exceptions.ConversionError:
+                ok("%s: Conversion OK" % name, False, False)
 
 finished()
 

Modified: trunk/test/python-tests/common.py
==============================================================================
--- trunk/test/python-tests/common.py	(original)
+++ trunk/test/python-tests/common.py	Sat Jan 19 05:20:44 2008
@@ -5,6 +5,7 @@
 import time
 import datetime
 import traceback
+import ConfigParser
 
 # make sure we have conduit folder in path!
 my_path = os.path.dirname(__file__)
@@ -88,11 +89,14 @@
     
 #Set a global exception hook for unhandled exceptions
 sys.excepthook = my_except_hook
+
+def get_data_dir():
+    return os.path.join(os.path.dirname(__file__),"data")
     
 #returns list of files that match the glob in the data dir
 def get_files_from_data_dir(glob_str):
     files = []
-    for i in glob.glob(os.path.join(os.path.dirname(__file__),"data",glob_str)):
+    for i in glob.glob(os.path.join(get_data_dir(),glob_str)):
         files.append(os.path.abspath(i))
     return files
 
@@ -104,7 +108,7 @@
 
 #returns the contents of the file called name in the data dir
 def read_data_file_from_data_dir(filename):
-    path = os.path.join(os.path.dirname(__file__),"data",filename)
+    path = os.path.join(get_data_dir(),filename)
     return read_data_file(path)
 
 def init_gnomevfs_authentication():
@@ -112,6 +116,27 @@
     gnome.init(conduit.APPNAME, conduit.APPVERSION)
     gnome.ui.authentication_manager_init()     
     
+def get_external_resources(typename):
+    #Reads the appropriate file (typename.list) and 
+    #returns a dict of name:uris beginning with subtypename
+    f = os.path.join(get_data_dir(),"%s.list" % typename)
+    data = {}
+    if os.path.exists(f):
+        config = ConfigParser.ConfigParser()
+        config.read(f)
+        #Default files first
+        if is_online():
+            for k,v in config.items('DEFAULT'):
+                data[k] = v
+
+        #Machine dependent items
+        section = Utils.get_user_string()
+        if config.has_section(section):
+            for k,v in config.items(section):
+                data[k] = v
+                
+    return data
+    
 #Functions to construct new types
 def new_file(filename):
     if filename == None:

Added: trunk/test/python-tests/data/audio.list
==============================================================================
--- (empty file)
+++ trunk/test/python-tests/data/audio.list	Sat Jan 19 05:20:44 2008
@@ -0,0 +1,15 @@
+#So that we dont have to keep a bunch of files in svn or on the web
+#to run the test suite on different machines, this file allows locations
+#to be specified in a section (as returned by Utils.get_user_string())
+#
+#Note: Items in the default section should always be accessible
+#Note: If two items have the same key, the one in your section replaces
+#the one in the default section
+[DEFAULT]
+mp3=http://www.recreantview.org/songs/jonobacon-freesoftwaresong.mp3
+ogg=http://www.recreantview.org/songs/jonobacon-freesoftwaresong.ogg
+
+[john nzjrs-desktop]
+mp3=/home/john/testing/test-data/jonobacon-freesoftwaresong.mp3
+ogg=/home/john/testing/test-data/jonobacon-freesoftwaresong.ogg
+

Added: trunk/test/python-tests/data/file.list
==============================================================================
--- (empty file)
+++ trunk/test/python-tests/data/file.list	Sat Jan 19 05:20:44 2008
@@ -0,0 +1,17 @@
+#So that we dont have to keep a bunch of files in svn or on the web
+#to run the test suite on different machines, this file allows locations
+#to be specified in a section (as returned by Utils.get_user_string())
+#
+#Note: Items in the default section should always be accessible
+#Note: If two items have the same key, the one in your section replaces
+#the one in the default section
+[DEFAULT]
+file1=http://tests.conduit-project.org/index.html
+file2=http://files.conduit-project.org/screenshot.jpg
+
+[john nzjrs-desktop]
+local=/home/john/eBooks/Wiley Global Positioning Systems Inertial Navigation and Integration (2nd Edition).pdf
+ssh=ssh://root greenbirdsystems com/var/www/conduit-project.org/files/screenshot.jpg
+ftp=ftp://anonymous 192 168 1 1/Status/index.htm
+
+

Added: trunk/test/python-tests/data/image.list
==============================================================================
--- (empty file)
+++ trunk/test/python-tests/data/image.list	Sat Jan 19 05:20:44 2008
@@ -0,0 +1,12 @@
+#So that we dont have to keep a bunch of files in svn or on the web
+#to run the test suite on different machines, this file allows locations
+#to be specified in a section (as returned by Utils.get_user_string())
+#
+#Note: Items in the default section should always be accessible
+#Note: If two items have the same key, the one in your section replaces
+#the one in the default section
+[DEFAULT]
+jpg=http://files.conduit-project.org/screenshot.jpg
+png=http://files.conduit-project.org/screenshot.png
+
+

Added: trunk/test/python-tests/data/video.list
==============================================================================
--- (empty file)
+++ trunk/test/python-tests/data/video.list	Sat Jan 19 05:20:44 2008
@@ -0,0 +1,17 @@
+#So that we dont have to keep a bunch of files in svn or on the web
+#to run the test suite on different machines, this file allows locations
+#to be specified in a section (as returned by Utils.get_user_string())
+#
+#Note: Items in the default section should always be accessible
+#Note: If two items have the same key, the one in your section replaces
+#the one in the default section
+[DEFAULT]
+ogg=http://files.conduit-project.org/Conduit-0.3.0-screencast-small.ogg
+
+[john nzjrs-desktop]
+ogg=/home/john/testing/test-data/Conduit-0.3.0-screencast-small.ogg
+flv=/home/john/testing/test-data/spyplane_080506_300k.flv
+avi=/home/john/testing/test-data/spyplane_080506_300k.avi
+mov=ftp://anonymous 192 168 1 1/Disk-1/Videos/alternativefreedomtrailer.mov
+wmv=ftp://anonymous 192 168 1 1/Disk-1/Videos/Daily Show/tds-question-mark.wmv
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]