conduit r1868 - in trunk: . conduit/platform test/python-tests



Author: jstowers
Date: Fri Feb 13 04:59:05 2009
New Revision: 1868
URL: http://svn.gnome.org/viewvc/conduit?rev=1868&view=rev

Log:
2009-02-13  John Stowers  <john stowers gmail com>

	* conduit/platform/FileGio.py: Copy the mtime
	when copying the file. Also check that copy
	and setting the mtime succeeds.

	* test/python-tests/TestSyncFolderFolder.py:
	Improve readability and make possible to test
	much larger numbers of files.



Modified:
   trunk/ChangeLog
   trunk/conduit/platform/FileGio.py
   trunk/test/python-tests/TestSyncFolderFolder.py

Modified: trunk/conduit/platform/FileGio.py
==============================================================================
--- trunk/conduit/platform/FileGio.py	(original)
+++ trunk/conduit/platform/FileGio.py	Fri Feb 13 04:59:05 2009
@@ -20,11 +20,11 @@
             try:
                 #FIXME: Only get attributes we actually care about
                 self.fileInfo = self._file.query_info("standard::*,time::*")
-                for ns in ("standard","time"):
-                    log.info("%s Attributes: %s" % (
-                            ns.title(),
-                            ','.join(self.fileInfo.list_attributes(ns)))
-                            )
+                #for ns in ("standard","time"):
+                #    log.info("%s Attributes: %s" % (
+                #            ns.title(),
+                #            ','.join(self.fileInfo.list_attributes(ns)))
+                #            )
                 self.fileExists = True
             except gio.Error:
                 self.fileExists = False
@@ -57,12 +57,11 @@
         
     def set_mtime(self, timestamp=None, datetime=None):
         try:
-            self._file.set_attribute_uint64(
-                        "time::modified",
-                        long(timestamp)
-                        )
-            self.close()
-            return timestamp
+            if self._file.set_attribute_uint64("time::modified", long(timestamp)):
+                self.close()
+                return timestamp
+            else:
+                return None
         except gio.Error, e:
             return None
         
@@ -262,14 +261,14 @@
             d.make_directory_and_parents()
 
         #Copy the file
-        try:        
+        try:      
             ok = self._source.copy(
                         destination=self._dest,
-                        flags=mode,
+                        flags=mode|gio.FILE_COPY_ALL_METADATA,
                         cancellable=self._cancellable,
                         progress_callback=self._xfer_progress_callback
                         )
-            return True, FileImpl(None, impl=self._dest)
+            return ok, FileImpl(None, impl=self._dest)
         except gio.Error, e:
             log.warn("File transfer error: %s" % e)
             return False, None

Modified: trunk/test/python-tests/TestSyncFolderFolder.py
==============================================================================
--- trunk/test/python-tests/TestSyncFolderFolder.py	(original)
+++ trunk/test/python-tests/TestSyncFolderFolder.py	Fri Feb 13 04:59:05 2009
@@ -11,7 +11,8 @@
 
 #Repeat syncs a few times to check for duplicate mapping bugs, etc
 SYNC_N_TIMES = 3
-#Num files to start with, should end with 150% of this number
+#Num files to start with, should end with 150% of this number, must be
+#an even integer
 NUM_FILES = 10
 #Sleep time for file I/O
 SLEEP_TIME = 1
@@ -70,16 +71,18 @@
     test.sync(debug = i == SYNC_N_TIMES and PRINT_MAPPING_DB)
     time.sleep(SLEEP_TIME)
 
+    nmaps = len(FILES)/2
+
     abort,error,conflict = test.get_sync_result()
     ok("Oneway Sync: Sync #%s completed" % i, abort == False and error == False and conflict == False)
 
     a = test.get_source_count()
     b = test.get_sink_count()
-    ok("Oneway Sync: Sync all items (%s,%s,%s)" % (a,b,len(FILES)), a==len(FILES)/2 and b==len(FILES))
+    ok("Oneway Sync: Sync all items (%s,%s,%s)" % (a,b,len(FILES)), a==nmaps and b==len(FILES))
 
     mapSource2Sink = conduit.GLOBALS.mappingDB.get_mappings_for_dataproviders(sourceW.get_UID(), sinkW.get_UID())
     mapSink2Source = conduit.GLOBALS.mappingDB.get_mappings_for_dataproviders(sinkW.get_UID(), sourceW.get_UID())
-    ok("Oneway Sync: 5 Mappings source -> sink", len(mapSource2Sink) == 5 and len(mapSink2Source) == 0)
+    ok("Oneway Sync: %s Mappings source -> sink" % nmaps, len(mapSource2Sink) == nmaps and len(mapSink2Source) == 0)
 
 #two way sync
 test.set_two_way_sync(True)
@@ -87,16 +90,18 @@
     test.sync(debug = i == SYNC_N_TIMES and PRINT_MAPPING_DB)
     time.sleep(SLEEP_TIME)
 
+    nmaps = len(FILES)
+
     abort,error,conflict = test.get_sync_result()
     ok("Sync: Sync #%s completed" % i, abort == False and error == False and conflict == False)
 
     a = test.get_source_count()
     b = test.get_sink_count()
-    ok("Sync: Sync all items (%s,%s,%s)" % (a,b,len(FILES)), a==len(FILES) and b==len(FILES))
+    ok("Sync: Sync all items (%s,%s,%s)" % (a,b,nmaps), a==nmaps and b==nmaps)
 
     mapSource2Sink = conduit.GLOBALS.mappingDB.get_mappings_for_dataproviders(sourceW.get_UID(), sinkW.get_UID())
     mapSink2Source = conduit.GLOBALS.mappingDB.get_mappings_for_dataproviders(sinkW.get_UID(), sourceW.get_UID())
-    ok("Sync: 10 Mappings in total", len(mapSource2Sink + mapSink2Source) == 10)
+    ok("Sync: %s Mappings in total" % nmaps, len(mapSource2Sink + mapSink2Source) == nmaps)
 
 for name,contents in FILES:
     f1 = File.File(os.path.join(sourceDir, name))
@@ -104,8 +109,10 @@
     comp = f1.compare(f2)
     ok("Sync: checking source/%s == sink/%s" % (name, name),comp == COMPARISON_EQUAL)
 
+
+
 #Now delete half the files
-for i in range(0, NUM_FILES/2):
+for i in range(0, len(FILES)/2):
     name, contents = FILES[i]
     #alternate deleting from source or sink
     if i % 2 == 0:
@@ -124,6 +131,8 @@
 for i in range(1,SYNC_N_TIMES+1):
     test.sync(debug = i == SYNC_N_TIMES and PRINT_MAPPING_DB)
     time.sleep(SLEEP_TIME)
+
+    nmaps = len(FILES)
     
     abort,error,conflict = test.get_sync_result()
     #There will only be a conflict (delete) the first sync, because the two way policy
@@ -132,10 +141,10 @@
 
     a = test.get_source_count()
     b = test.get_sink_count()
-    ok("Delete: Files were deleted (%s,%s,%s)" % (a,b,len(FILES)), a==len(FILES) and b==len(FILES))
+    ok("Delete: Files were deleted (%s,%s,%s)" % (a,b,nmaps), a==nmaps and b==nmaps)
     mapSource2Sink = conduit.GLOBALS.mappingDB.get_mappings_for_dataproviders(sourceW.get_UID(), sinkW.get_UID())
     mapSink2Source = conduit.GLOBALS.mappingDB.get_mappings_for_dataproviders(sinkW.get_UID(), sourceW.get_UID())
-    ok("Delete: 5 Mappings in total", len(mapSource2Sink + mapSink2Source) == 5)
+    ok("Delete: %s Mappings in total" % nmaps, len(mapSource2Sink + mapSink2Source) == nmaps)
 
 
 for name,contents in FILES:
@@ -175,16 +184,17 @@
 for i in range(1,SYNC_N_TIMES+1):
     test.sync(debug = i == SYNC_N_TIMES and PRINT_MAPPING_DB)
     time.sleep(SLEEP_TIME)
+
+    nmaps = len(FILES)
     
     abort,error,conflict = test.get_sync_result()
     ok("Hidden: Sync #%s completed" % i, abort == False and error == False and conflict == False)
 
     a = test.get_source_count()
     b = test.get_sink_count()
-    ok("Hidden: Sync all items (%s,%s,%s)" % (a,b,len(FILES)), a==len(FILES) and b==len(FILES))
+    ok("Hidden: Sync all items (%s,%s,%s)" % (a,b,nmaps), a==nmaps and b==nmaps)
     mapSource2Sink = conduit.GLOBALS.mappingDB.get_mappings_for_dataproviders(sourceW.get_UID(), sinkW.get_UID())
     mapSink2Source = conduit.GLOBALS.mappingDB.get_mappings_for_dataproviders(sinkW.get_UID(), sourceW.get_UID())
-    ok("Hidden: 15 Mappings in total", len(mapSource2Sink + mapSink2Source) == 15)
-
+    ok("Hidden: %s Mappings in total" % nmaps, len(mapSource2Sink + mapSink2Source) == nmaps)
 
 finished()



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