[conduit: 71/138] Start sketching out magic to allow where source.dataclass != sink.dataclass
- From: John Carr <johncarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [conduit: 71/138] Start sketching out magic to allow where source.dataclass != sink.dataclass
- Date: Thu, 21 May 2009 03:32:53 -0400 (EDT)
commit 279303aea9fd23500c96a8511e7457aca54d28ee
Author: John Carr <john carr unrouted co uk>
Date: Sun May 3 05:04:10 2009 -0700
Start sketching out magic to allow where source.dataclass != sink.dataclass
---
test/soup/test_synchronization.py | 53 +++++++++++++++++++++++++------------
1 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/test/soup/test_synchronization.py b/test/soup/test_synchronization.py
index a8727ed..8452b87 100644
--- a/test/soup/test_synchronization.py
+++ b/test/soup/test_synchronization.py
@@ -1,22 +1,23 @@
import soup
-def make_testcase(src, snk, dcls):
+def make_testcase(src, src_data, snk, snk_data):
class TestSynchronization(soup.TestCase):
- source_klass = src
- sink_klass = snk
- dataclass = dcls
+ source_class = src
+ source_data_class = src_data
+ sink_class = snk
+ sink_data_class = snk_data
@classmethod
def name(self):
- return "TestSynchronization%s%s" % (self.source_klass.name(), self.sink_klass.name())
+ return "TestSynchronization%s%s" % (self.source_class.name(), self.sink_class.name())
def setUp(self):
self.setUpSync()
- self.data = self.dataclass()
-
- self.source = self.source_klass(self)
- self.sink = self.sink_klass(self)
+ self.source = self.source_class(self)
+ self.source_data = self.source_data_class()
+ self.sink = self.sink_class(self)
+ self.sink_data = self.sink_data_class()
self.pair = self.create_conduit()
self.pair.add_dataprovider(self.source.get_wrapped())
@@ -26,17 +27,17 @@ def make_testcase(src, snk, dcls):
self.pair.set_policy("conflict", "replace")
self.pair.set_policy("deleted", "replace")
- def add_testdata(self, target):
+ def add_testdata(self, target, target_data):
count = 0
- for data in self.data.iter_samples():
+ for data in target_data.iter_samples():
count += 1
target.add(data)
return count
- def modify_testdata(self, target):
+ def modify_testdata(self, target, target_data):
uids = target.get_all()
for uid in uids:
- data = self.data.mutate_sample(target.get(uid))
+ data = target_data.mutate_sample(target.get(uid))
target.replace(uid, data)
def check_state(self, expected):
@@ -54,7 +55,7 @@ def make_testcase(src, snk, dcls):
def test_add_to_source(self):
""" should be able to add data to source then sync """
- added = self.add_testdata(self.source)
+ added = self.add_testdata(self.source, self.source_data)
self.pair.sync(block=True)
self.check_state(added)
@@ -74,7 +75,7 @@ def make_testcase(src, snk, dcls):
def test_add_to_sink(self):
""" should be able to add data to sink then sync """
- added = self.add_testdata(self.sink)
+ added = self.add_testdata(self.sink, self.sink_data)
self.pair.sync(block=True)
self.check_state(added)
@@ -102,11 +103,29 @@ for i in range(len(mods)):
for j in range(i+1, len(mods)):
source = mods[i]
sink = mods[j]
- if not sink.dataclass.is_compatible(source.dataclass.get_datatype()) and not source.dataclass.is_compatible(sink.dataclass.get_datatype()):
+
+ # Cludge: If we have 2 different datatypes, we implicity use a wrapper
+ # that converts from the most specialized to the lease specialized datatype.
+ # That way we have Contact files instead of Mp3 files etc.
+ if source.dataclass == sink.dataclass:
+ source_data = source.dataclass
+ sink_data = sink.dataclass
+ #elif source.dataclass.is_compatible(sink.dataclass.get_datatype():
+ # source_data = source.dataclass
+ # sink_data = # conversion thingy here
+ #elif sink.dataclass.is_compatible(source.dataclass.get_datatype()):
+ # source_data = # conversion thingy here
+ # sink_data = sink.dataclass
+ else:
continue
+
+ # Right now we only test twoway sync. We should seperate the twoway specific tests out.
+ # We should also test slow-sync *shrug*
if not source.is_twoway() or not sink.is_twoway():
continue
- testklass = make_testcase(source, sink, sink.dataclass)
+
+ # Actually generate a testcase for this..
+ testklass = make_testcase(source, source_data, sink, sink_data)
setattr(self, testklass.name(), testklass)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]