conduit r1213 - in trunk: . conduit/modules test/python-tests



Author: jstowers
Date: Mon Jan 14 08:20:46 2008
New Revision: 1213
URL: http://svn.gnome.org/viewvc/conduit?rev=1213&view=rev

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

	* conduit/modules/TestModule.py: Add TestFileTwoWay and change the
	default behaviour for emitting change_detected to require configuring the
	dataprovider
	
	* test/python-tests/TestCoreSyncTestDataProviders.py: Test TestFileTwoWay



Modified:
   trunk/ChangeLog
   trunk/conduit/modules/TestModule.py
   trunk/test/python-tests/TestCoreSyncTestDataProviders.py

Modified: trunk/conduit/modules/TestModule.py
==============================================================================
--- trunk/conduit/modules/TestModule.py	(original)
+++ trunk/conduit/modules/TestModule.py	Mon Jan 14 08:20:46 2008
@@ -23,6 +23,7 @@
     "TestWebTwoWay" :           { "type": "dataprovider" },
     "TestFileSource" :          { "type": "dataprovider" },
     "TestFileSink" :            { "type": "dataprovider" },
+    "TestFileTwoWay" :          { "type": "dataprovider" },
     "TestImageSink" :           { "type": "dataprovider" },
     "TestVideoSink" :           { "type": "dataprovider" },
     "TestAudioSink" :           { "type": "dataprovider" },
@@ -107,6 +108,9 @@
         self.aList = []
         self.count = 0
         
+    def _change_detected(self, *args):
+        gobject.timeout_add(3000, self.emit_change_detected)    
+        
     def initialize(self):
         return True
 
@@ -162,7 +166,13 @@
                     "Widget" : gtk.Entry,
                     "Callback" : setNumData,
                     "InitialValue" : self.numData
-                    } 
+                    },
+                    {
+                    "Name" : "Emit Change Detected",
+                    "Widget" : gtk.CheckButton,
+                    "Callback" : self._change_detected,
+                    "InitialValue" : False
+                    }
                 ]
         dialog = SimpleConfigurator.SimpleConfigurator(window, self._name_, items)
         dialog.run()
@@ -240,13 +250,6 @@
         self.data = []
         self.numData = 10
         
-        #signal we have new data in a few seconds
-        gobject.timeout_add(3000, self._emit_change)
-
-    def _emit_change(self):
-        self.emit_change_detected()
-        return False
-        
     def refresh(self):
         DataProvider.DataSource.refresh(self)
         self.data = []
@@ -373,8 +376,25 @@
     def put(self, data, overwrite, LUID=None):
         log.debug("Putting file: %s" % data._get_text_uri())
         DataProvider.DataSink.put(self, data, overwrite, LUID)
-        newData = TestDataType(data.get_size())
-        return newData.get_rid()
+        if LUID == None:
+            LUID = data.get_UID()
+        f = File.File(URI=LUID)
+        f.set_UID(LUID)
+        return f.get_rid()
+        
+class TestFileTwoWay(TestFileSource, TestFileSink):
+
+    _name_ = "Test File Two Way"
+    _description_ = "Sync Files"
+    _category_ = conduit.dataproviders.CATEGORY_TEST
+    _module_type_ = "twoway"
+    _in_type_ = "file"
+    _out_type_ = "file"
+    _icon_ = "text-x-generic"
+
+    def __init__(self, *args):
+        TestFileSource.__init__(self)
+        TestFileSink.__init__(self)
 
 class TestImageSink(_TestBase, Image.ImageSink):
 

Modified: trunk/test/python-tests/TestCoreSyncTestDataProviders.py
==============================================================================
--- trunk/test/python-tests/TestCoreSyncTestDataProviders.py	(original)
+++ trunk/test/python-tests/TestCoreSyncTestDataProviders.py	Mon Jan 14 08:20:46 2008
@@ -133,7 +133,7 @@
 ###
 ok("---- ONE WAY: TEST FILE/IMAGE SINK", True)
 test = SimpleSyncTest()
-test.set_two_way_policy({"conflict":"skip","deleted":"skip"})
+test.set_two_way_policy({"conflict":"ask","deleted":"ask"})
 test.prepare(
         test.get_dataprovider("TestFileSource"), 
         test.get_dataprovider("TestFileSink")
@@ -143,7 +143,22 @@
         )
 test.set_two_way_sync(False)
 test.sync(debug=False)
-aborted = test.sync_aborted()
-ok("Sync completed", aborted == False)
+aborted,errored,conflicted = test.get_sync_result()
+ok("Sync completed without conflicts", aborted == False and errored == False and conflicted == False)
+
+###
+#Test file and image sink
+###
+ok("---- TWO WAY: TEST FILE", True)
+test = SimpleSyncTest()
+test.set_two_way_policy({"conflict":"ask","deleted":"ask"})
+test.prepare(
+        test.get_dataprovider("TestFileTwoWay"), 
+        test.get_dataprovider("TestFileTwoWay")
+        )
+test.set_two_way_sync(True)
+test.sync(debug=False)
+aborted,errored,conflicted = test.get_sync_result()
+ok("Sync completed without conflicts", aborted == False and errored == False and conflicted == False)
 
 finished()



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