Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar/tutorius/tests
diff options
context:
space:
mode:
authorJean-Christophe Savard <savard.jean.christophe@gmail.com>2009-04-25 01:28:46 (GMT)
committer Jean-Christophe Savard <savard.jean.christophe@gmail.com>2009-04-25 01:28:46 (GMT)
commit7b434e2f601aeea6be5b12e1e954a95f4e77b69d (patch)
tree6404e804da404dc95b6cccebdc4738a0c20dc078 /src/sugar/tutorius/tests
parentfc97ecd62b0a28079c91178f5257ce9d14a97a98 (diff)
final debugging on bundler.py and update on tests in serializertests.py
Diffstat (limited to 'src/sugar/tutorius/tests')
-rw-r--r--src/sugar/tutorius/tests/serializertests.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/sugar/tutorius/tests/serializertests.py b/src/sugar/tutorius/tests/serializertests.py
index 64e467e..b138fa3 100644
--- a/src/sugar/tutorius/tests/serializertests.py
+++ b/src/sugar/tutorius/tests/serializertests.py
@@ -28,7 +28,7 @@ import unittest
import logging
import linecache
import os
-import cPickle as pickle
+import shutil
from sugar.tutorius import gtkutils, overlayer
from sugar.tutorius.core import Tutorial, State, FiniteStateMachine
@@ -63,10 +63,12 @@ class XMLSerializerTest(unittest.TestCase):
self.fsm.add_state(st2)
self.uuid = uuid1()
+
- def test_save(self):
+ def test_save(self, remove=True):
"""
Writes an FSM to disk, then compares the file to the expected results.
+ "Remove" boolean argument specify if the test data must be removed or not
"""
# Make the serializer believe the test is in a activity path
testpath = "/tmp/testdata/"
@@ -78,19 +80,18 @@ class XMLSerializerTest(unittest.TestCase):
#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
+ if remove == True:
+ os.remove(os.path.join(sugar.tutorius.bundler._get_store_root(), str(self.uuid)) + "/fsm.xml")
+ if os.path.isdir(testpath):
+ shutil.rmtree(testpath)
- #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.
"""
- self.test_save()
-
+ self.test_save(False)
+ testpath = "/tmp/testdata/"
#rpdb2.start_embedded_debugger('flakyPass')
xml_ser = XMLSerializer()
@@ -101,12 +102,21 @@ class XMLSerializerTest(unittest.TestCase):
# 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, \
+ assert loaded_fsm._states.get("Second").name == self.fsm._states.get("Second").name, \
'FSM underlying dictionary differ from original to pickled/reformed one'
+ assert loaded_fsm._states.get("INIT").get_action_list()[0].get_message() == \
+ self.fsm._states.get("INIT").get_action_list()[0].get_message(), \
+ 'FSM underlying State underlying Action differ from original to reformed one'
+
+ os.remove(os.path.join(sugar.tutorius.bundler._get_store_root(), str(self.uuid)) + "/fsm.xml")
+ if os.path.isdir(testpath):
+ shutil.rmtree(testpath)
+
# Helper classes to help testing
class SerializerTest(unittest.TestCase):
"""
+
This class has to test the Serializer methods as well as the expected
functionality.
"""