diff options
Diffstat (limited to 'src/sugar/tutorius/tests/serializertests.py')
-rw-r--r-- | src/sugar/tutorius/tests/serializertests.py | 23 |
1 files changed, 17 insertions, 6 deletions
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() |