diff options
author | mike <michael.jmontcalm@gmail.com> | 2009-11-14 20:42:57 (GMT) |
---|---|---|
committer | mike <michael.jmontcalm@gmail.com> | 2009-11-14 20:42:57 (GMT) |
commit | f3fd1f4350be622c76cb67baf93efb0e3505c4c2 (patch) | |
tree | 20e65e3b8acd4e01e5cbac1788228187658e068a | |
parent | 749f6f51e10c536847a209fb1706583e2a6ad883 (diff) |
Fixing tests (removing @catch_unimplemented, fixing paths, merging engine tests)
-rw-r--r-- | tests/enginetests.py | 65 | ||||
-rw-r--r-- | tests/storetests.py | 12 | ||||
-rw-r--r-- | tests/vaulttests.py | 6 |
3 files changed, 59 insertions, 24 deletions
diff --git a/tests/enginetests.py b/tests/enginetests.py index 60a68f4..c3ccf67 100644 --- a/tests/enginetests.py +++ b/tests/enginetests.py @@ -13,18 +13,67 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +""" +Core Tests + +This module contains all the tests that pertain to the usage of the Tutorius +Core. This means that the Event Filters, the Finite State Machine and all the +related elements and interfaces are tested here. + +Usage of actions and event filters is tested, but not the concrete actions +and event filters. Those are in their separate test module + +""" import unittest -import dbus +from copy import deepcopy + +from sugar.tutorius.tutorial import Tutorial +from sugar.tutorius.engine import TutorialRunner + +from actiontests import CountAction, FakeEventFilter + +class MockProbeMgr(object): + def __init__(self): + self.action = None + self.event = None + self.cB = None + + def doCB(self): + self.cB(self.event) + + currentActivity = property(fget=lambda s:s, fset=lambda s, v: v) + + def install(self, action, block=False): + self.action = action + + def update(self, action, newaction, block=False): + self.action = newaction + + def uninstall(self, action, block=False): + self.action = None + + def subscribe(self, event, callback): + self.event = event + self.cB = callback + return str(event) -session_bus = dbus.SessionBus() + def unsubscribe(self, address): + self.event = address -ENGINE_BUS_NAME = "org.tutorius.engine" +class TutorialRunnerTest(unittest.TestCase): + """ + This class needs to test the TutorialRunner + """ + def setUp(self): + self.pM = MockProbeMgr() + self.runner = TutorialRunner(self.pM) -LAUNCH_PATH = "/launch" -STOP_PATH = "/stop" -PAUSE_PATH = "/pause" + def tearDown(self): + self.runner = None + self.pM = None -class EngineInterfaceTests(unittest.TestCase): - pass + +if __name__ == "__main__": + unittest.main() diff --git a/tests/storetests.py b/tests/storetests.py index 0c36973..3f1b73c 100644 --- a/tests/storetests.py +++ b/tests/storetests.py @@ -31,13 +31,11 @@ class StoreProxyTest(unittest.TestCase): def tearDown(self): pass - @catch_unimplemented def test_get_categories(self): categories = self.store.get_categories() assert isinstance(categories, list), "categories should be a list" - @catch_unimplemented def test_get_tutorials(self): self.store.get_tutorials() @@ -46,17 +44,14 @@ class StoreProxyTest(unittest.TestCase): assert isinstance(version_dict, dict) - @catch_unimplemented def test_download_tutorial(self): tutorial = self.store.download_tutorial(g_other_id) assert tutorial is not None - @catch_unimplemented def test_login(self): assert self.store.login("benoit.tremblay1@gmail.com", "tutorius12") - @catch_unimplemented def test_register_new_user(self): random_num = str(random.randint(0, 999999999)) user_info = { @@ -69,29 +64,24 @@ class StoreProxyTest(unittest.TestCase): class StoreProxyLoginTest(unittest.TestCase): - @catch_unimplemented def setUp(self): self.store = StoreProxy("http://bobthebuilder.mine.nu/tutorius/en-US/tutorius") self.store.login("nobody@mozilla.org", "tutorius12") - @catch_unimplemented def tearDown(self): session_id = self.store.get_session_id() if session_id is not None: self.store.close_session() - @catch_unimplemented def test_get_session_id(self): session_id = self.store.get_session_id() assert session_id is not None - @catch_unimplemented def test_rate(self): assert self.store.rate(5, g_tutorial_id) - @catch_unimplemented def test_publish(self): # TODO : We need to send in a real tutorial loaded from # the Vault @@ -108,7 +98,6 @@ class StoreProxyLoginTest(unittest.TestCase): } assert self.store.publish('This should be a real tutorial...', tutorial_info) != -1 - @catch_unimplemented def test_unpublish(self): assert self.store.unpublish(g_tutorial_id) @@ -118,7 +107,6 @@ class StoreProxyLoginTest(unittest.TestCase): def test_republish(self): assert self.store.publish(None, None, g_tutorial_id) - @catch_unimplemented def test_update_published_tutorial(self): # TODO : Run these tests with files from the Vault #self.store.publish([g_tutorial_id, 'Fake tutorial']) diff --git a/tests/vaulttests.py b/tests/vaulttests.py index 0af2d65..9bd0525 100644 --- a/tests/vaulttests.py +++ b/tests/vaulttests.py @@ -275,8 +275,8 @@ class VaultInterfaceTest(unittest.TestCase): bundler = TutorialBundler(self.save_test_guid) tuto_path = bundler.get_tutorial_path(self.save_test_guid) - # add the ressource to the tutorial - ressource_id = Vault.add_resource(self.save_test_guid, image_path) + # add the resource to the tutorial + resource_id = Vault.add_resource(self.save_test_guid, image_path) # Check that the image file is now in the vault assert os.path.isfile(os.path.join(tuto_path, 'resources', resource_id)), 'image file not found in vault' @@ -294,8 +294,6 @@ class VaultInterfaceTest(unittest.TestCase): # Check that the resource is not in the vault anymore assert os.path.isfile(os.path.join(tuto_path, 'resources', resource_id)) == False, 'image file found in vault when it should have been deleted.' - - def tearDown(self): folder = os.path.join(os.getenv("HOME"),".sugar", 'default', 'tutorius', 'data'); for file in os.listdir(folder): |