[conduit: 50/138] Add a few more test scenarios



commit d728f2246ede71f6e6884e1dc66b4ef1a1dd32dc
Author: John Carr <john carr unrouted co uk>
Date:   Thu Apr 30 01:28:20 2009 -0700

    Add a few more test scenarios
---
 test/soup/modules/__init__.py     |    8 ++++++++
 test/soup/test_synchronization.py |   32 ++++++++++++++++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/test/soup/modules/__init__.py b/test/soup/modules/__init__.py
index 1462bcc..7757d11 100644
--- a/test/soup/modules/__init__.py
+++ b/test/soup/modules/__init__.py
@@ -20,6 +20,10 @@ class ModuleWrapper(object):
             self.dp.finish()
         return count
 
+    def get_all(self):
+        self.dp.refresh()
+        return self.dp.get_all()
+
     def get(self, uid):
         return self.dp.get(uid)
 
@@ -32,6 +36,10 @@ class ModuleWrapper(object):
     def delete(self, uid):
         self.dp.delete(uid)
 
+    def delete_all(self):
+        for uid in self.get_all():
+            self.delete(uid)
+
     def apply_changes(self, uid):
         for t, uid, obj in changes:
             if t == CHANGE_ADD:
diff --git a/test/soup/test_synchronization.py b/test/soup/test_synchronization.py
index 031b21e..1296d8d 100644
--- a/test/soup/test_synchronization.py
+++ b/test/soup/test_synchronization.py
@@ -22,22 +22,50 @@ def make_testcase(src, snk, dcls):
             self.pair.add_dataprovider(self.source.get_wrapped())
             self.pair.add_dataprovider(self.sink.get_wrapped())
 
+        def tearDown(self):
+            # we always do a no changes sync at the end, and make sure there are no changes...
+            self.pair.sync(block=True)
+
         def test_empty_sync(self):
             """ test empty synchronisation """
             self.pair.sync(block=True)
 
         def test_add_to_source(self):
-            """ testing adding data to source """
+            """ should be able to add data to source then sync """
             for data in self.data.iter_samples():
                 self.source.add(data)
             self.pair.sync(block=True)
 
+        def test_add_source_delete_source(self):
+            """ should be able to add data at source, sync, delete data from source then sync """
+            self.test_add_to_source()
+            self.source.delete_all()
+            self.pair.sync(block=True)
+
+        def test_add_source_delete_sink(self):
+            """ should be able to add data at source, sync, delete at sink, then sync """
+            self.test_add_to_source()
+            self.sink.delete_all()
+            self.pair.sync(block=True)
+
         def test_add_to_sink(self):
-            """ test adding data to sink """
+            """ should be able to add data to sink then sync """
             for data in self.data.iter_samples():
                 self.sink.add(data)
             self.pair.sync(block=True)
 
+        def test_add_sink_delete_source(self):
+            """ should be able to add data at sink, sync, delete at source, then sync """
+            self.test_add_to_sink()
+            self.source.delete_all()
+            self.pair.sync(block=True)
+
+        def test_add_sink_delete_sink(self):
+            """ should be able to add data at sink, sync, delete at sink, then sync """
+            self.test_add_to_sink()
+            self.sink.delete_all()
+            self.pair.sync(block=True)
+
     return TestSynchronization
 
 



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