[conduit: 19/138] Start testing stuff somewhat



commit 4cc8ccb6eff9e6700b1e45bff5625220c3cdcb99
Author: John Carr <john carr unrouted co uk>
Date:   Mon Apr 20 10:59:21 2009 -0700

    Start testing stuff somewhat
---
 test/soup/__init__.py          |   27 +++++++++++++++++----------
 test/soup/modules/ipod.py      |    2 ++
 test/soup/run-tests.sh         |    1 +
 test/soup/test_dataprovider.py |   14 +++++++++++---
 4 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/test/soup/__init__.py b/test/soup/__init__.py
index 1f2c5ce..593365f 100644
--- a/test/soup/__init__.py
+++ b/test/soup/__init__.py
@@ -1,13 +1,23 @@
 
 import os, sys
 cwd = os.path.dirname(__file__)
-sys.path.insert(0, os.path.abspath(os.path.join(cwd, '..', '..')))
+root = os.path.abspath(os.path.join(cwd, '..', '..'))
+sys.path.insert(0, root)
 
 import unittest
 
 import modules
 import data
 
+import conduit
+import conduit.utils as Utils
+import conduit.MappingDB as MappingDB
+import conduit.Module as Module
+import conduit.TypeConverter as TypeConverter
+import conduit.Synchronization as Synchronization
+
+conduit.SHARED_MODULE_DIR = os.path.join(root,"conduit","modules")
+
 CHANGE_ADD = 1
 CHANGE_REPLACE = 2
 CHANGE_DELETE = 3
@@ -18,31 +28,28 @@ def get_module(name):
 
 class TestCase(unittest.TestCase):
 
-    def grumpy(self):
+    def setUp(self):
         #Set up our own mapping DB so we dont pollute the global one
         dbFile = os.path.join(os.environ['TEST_DIRECTORY'],Utils.random_string()+".db")
         conduit.GLOBALS.mappingDB = MappingDB.MappingDB(dbFile)
 
-        self.modules = Module.ModuleManager(dirs)
+        self.modules = Module.ModuleManager([root])
         conduit.GLOBALS.moduleManager = self.modules
         self.modules.load_all(whitelist=None, blacklist=None)
 
-        self.type_converter = TypeConverter.TypeConverter(self.modules)
+        self.type_converter = conduit.TypeConverter.TypeConverter(self.modules)
         conduit.GLOBALS.typeConverter = self.type_converter
-        self.sync_manager = Synchronization.SyncManager(self.type_converter)
+        self.sync_manager = conduit.Synchronization.SyncManager(self.type_converter)
         conduit.GLOBALS.syncManager = self.sync_manager
 
-    def setUp(self):
-        pass
-
     def tearDown(self):
         pass
 
     def get_dataprovider(self, key):
         wrapper = None
-        for dp in self.model.get_all_modules():
+        for dp in self.modules.get_all_modules():
             if dp.classname == name:
-                wrapper = self.model.get_module_wrapper_with_instance(dp.get_key())
+                wrapper = self.modules.get_module_wrapper_with_instance(dp.get_key())
         assert wrapper != None
         return wrapper
 
diff --git a/test/soup/modules/ipod.py b/test/soup/modules/ipod.py
index b9b3371..956f278 100644
--- a/test/soup/modules/ipod.py
+++ b/test/soup/modules/ipod.py
@@ -1,6 +1,8 @@
 
 import soup.modules
 
+import conduit.utils as Utils
+
 class iPodCalendar(soup.modules.ModuleWrapper):
 
     def create_dataprovider(self):
diff --git a/test/soup/run-tests.sh b/test/soup/run-tests.sh
index 7462d8b..1ddbc34 100755
--- a/test/soup/run-tests.sh
+++ b/test/soup/run-tests.sh
@@ -1,2 +1,3 @@
 #! /bin/sh
+export TEST_DIRECTORY=tmp
 PYTHONPATH=.. python test_dataprovider.py
diff --git a/test/soup/test_dataprovider.py b/test/soup/test_dataprovider.py
index a1580e1..c83e910 100644
--- a/test/soup/test_dataprovider.py
+++ b/test/soup/test_dataprovider.py
@@ -4,8 +4,15 @@ def make_testcase(dp):
     class TestDataprovider(soup.TestCase):
         dataprovider = dp
 
+        def setUp(self):
+            super(TestDataprovider, self).setUp()
+            self.dp = self.dataprovider(self)
+
+        def tearDown(self):
+            self.dp = None
+
         def test_add(self):
-            assert self.dataprovider != None
+            pass
 
         def test_replace(self):
             pass
@@ -17,10 +24,11 @@ def make_testcase(dp):
             pass
 
         def test_finish(self):
-            pass
+            self.dp.finish()
 
         def test_get_num_items(self):
-            pass
+            self.dp.refresh()
+            assert self.dp.get_num_items() == 0
 
     return TestDataprovider
 



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