From a4114a946cc7a57c1cfce5760737c3f05425bc86 Mon Sep 17 00:00:00 2001 From: mike Date: Sun, 26 Apr 2009 18:55:55 +0000 Subject: Merge branch 'jc' of ssh://mike@bobthebuilder.mine.nu:8080/home/git into jc_support --- (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 6f22fee..97665f7 100755 --- a/src/sugar/tutorius/tests/run-tests.py +++ b/src/sugar/tutorius/tests/run-tests.py @@ -10,10 +10,17 @@ sys.path.insert(0, ) FULL_PATH = os.path.join(INSTALL_PATH,"sugar/tutorius") +SUBDIRS = ["uam"] GLOB_PATH = os.path.join(FULL_PATH,"*.py") import unittest from glob import glob +def report_files(): + ret = glob(GLOB_PATH) + for dir in SUBDIRS: + ret += glob(os.path.join(FULL_PATH,dir,"*.py")) + return ret + import sys if __name__=='__main__': if "--coverage" in sys.argv: @@ -28,26 +35,41 @@ if __name__=='__main__': import gtkutilstests import overlaytests import linear_creatortests + import actiontests + import uamtests + import filterstests + import constraintstests + import propertiestests import serializertests - suite = unittest.TestSuite() suite.addTests(unittest.findTestCases(coretests)) suite.addTests(unittest.findTestCases(servicestests)) suite.addTests(unittest.findTestCases(gtkutilstests)) suite.addTests(unittest.findTestCases(overlaytests)) suite.addTests(unittest.findTestCases(linear_creatortests)) - suite.addTests(unittest.findTestCases(serializertests)) - + suite.addTests(unittest.findTestCases(actiontests)) + suite.addTests(unittest.findTestCases(uamtests)) + suite.addTests(unittest.findTestCases(filterstests)) + suite.addTests(unittest.findTestCases(constraintstests)) + suite.addTests(unittest.findTestCases(propertiestests)) + suite.addTests(unittest.findTestCases(serializertests)) runner = unittest.TextTestRunner() runner.run(suite) coverage.stop() - coverage.report(glob(GLOB_PATH)) + coverage.report(report_files()) coverage.erase() else: from coretests import * from servicestests import * from gtkutilstests import * from overlaytests import * + from actiontests import * + from linear_creatortests import * + from uamtests import * + from filterstests import * + from constraintstests import * + from propertiestests import * + from actiontests import * from serializertests import * unittest.main() diff --git a/src/sugar/tutorius/tests/serializertests.py b/src/sugar/tutorius/tests/serializertests.py index 0b7fabd..75fe8eb 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. """ -- cgit v0.9.1