From dba2da918dda60778a35e992ffc8f94989272977 Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 22 Apr 2009 19:01:01 +0000 Subject: Merge branch 'jc' of ssh://mike@bobthebuilder.mine.nu:8080/home/git into jc_support Conflicts: source/external/source/sugar-toolkit/src/sugar/tutorius/bundler.py source/external/source/sugar-toolkit/src/sugar/tutorius/tests/serializertests.py --- (limited to 'src/sugar/tutorius/tests') diff --git a/src/sugar/tutorius/tests/run-tests.py b/src/sugar/tutorius/tests/run-tests.py index 0c9219b..6f22fee 100755 --- a/src/sugar/tutorius/tests/run-tests.py +++ b/src/sugar/tutorius/tests/run-tests.py @@ -48,5 +48,6 @@ if __name__=='__main__': from servicestests import * from gtkutilstests import * from overlaytests import * + from serializertests import * unittest.main() diff --git a/src/sugar/tutorius/tests/serializertests.py b/src/sugar/tutorius/tests/serializertests.py index 9a21d08..0b7fabd 100644 --- a/src/sugar/tutorius/tests/serializertests.py +++ b/src/sugar/tutorius/tests/serializertests.py @@ -67,15 +67,24 @@ class XMLSerializerTest(unittest.TestCase): def test_save(self): """ Writes an FSM to disk, then compares the file to the expected results. - """ + """ + # Make the serializer believe the test is in a activity path + testpath = "/tmp/testdata/" + os.environ["SUGAR_BUNDLE_PATH"] = testpath + os.environ["SUGAR_PREFIX"] = testpath +## os.mkdir(sugar.tutorius.bundler._get_store_root()) xml_ser = XMLSerializer() - os.mkdir(os.path.join(sugar.tutorius.bundler._get_store_root(), str(self.uuid))) + os.makedirs(os.path.join(sugar.tutorius.bundler._get_store_root(), str(self.uuid))) #rpdb2.start_embedded_debugger('flakyPass') xml_ser.save_fsm(self.fsm, "fsm.xml", os.path.join(sugar.tutorius.bundler._get_store_root(), str(self.uuid))) # Compare the two files - + + #Remove test file and path (commented for testing, to uncomment) +## os.remove(testpath + os.path.join(sugar.tutorius.bundler._get_store_root(), str(self.uuid)) + "/fsm.xml") +## os.removedirs(testpath) + def test_save_and_load(self): """ Load up the written FSM and compare it with the object representation. @@ -85,13 +94,15 @@ class XMLSerializerTest(unittest.TestCase): #rpdb2.start_embedded_debugger('flakyPass') xml_ser = XMLSerializer() - rpdb2.start_embedded_debugger('pass') # This interface needs to be redone... It's not clean because there is # a responsibility mixup between the XML reader and the bundler. loaded_fsm = xml_ser.load_fsm(str(self.uuid)) # Compare the two FSMs - + assert loaded_fsm._states.get("INIT").name == self.fsm._states.get("INIT").name, \ + 'FSM underlying dictionary differ from original to pickled/reformed one' + assert loaded_fsm._states.get("LOST").name == self.fsm._states.get("Second").name, \ + 'FSM underlying dictionary differ from original to pickled/reformed one' # Helper classes to help testing class SerializerTest(unittest.TestCase): @@ -172,4 +183,4 @@ class SerializerTest(unittest.TestCase): if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() -- cgit v0.9.1