From 4f2d6d7e1820a3e5d6d60e3100993c5f1b6fb9ad Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 25 Nov 2009 19:14:20 +0000 Subject: Merge branch 'noblock_engine' of git://git.sugarlabs.org/tutorius/mainline into noblock_engine Conflicts: tests/enginetests.py tutorius/engine.py tutorius/properties.py --- (limited to 'tests') diff --git a/tests/enginetests.py b/tests/enginetests.py index 7fddd15..4a8a3ca 100644 --- a/tests/enginetests.py +++ b/tests/enginetests.py @@ -35,6 +35,55 @@ from sugar.tutorius.actions import Action from sugar.tutorius.filters import EventFilter from actiontests import CountAction +class MockProbeMgrMultiAddons(object): + def __init__(self): + self.action_dict = {} + self.event_dict = {} + self.event_cb_dict = {} + + self._action_installed_cb_list = [] + self._install_error_cb_list = [] + self._event_subscribed_cb_list = [] + self._subscribe_error_cb_list = [] + + currentActivity = property(fget=lambda s:s, fset=lambda s, v: v) + + def run_install_cb(self, action_number, action): + self._action_installed_cb_list[action_number](action, str(uuid1())) + + def run_install_error_cb(self, action_number): + self._install_error_cb_list[action_number](Exception("Could not install action...")) + + def run_subscribe_cb(self, event_number): + self._event_subscribed_cb_list[event_number](str(uuid1())) + + def run_subscribe_error(self, event_number): + self._subscribe_error_cb_list[event_number](str(uuid1())) + + def install(self, action, action_installed_cb, error_cb): + action_address = str(uuid1()) + self.action_dict[action_address] = action + self._action_installed_cb_list.append(action_installed_cb) + self._install_error_cb_list.append(error_cb) + + def update(self, action_address, new_action): + self.action_dict[action_address] = new_action + + def uninstall(self, action_address): + del self.action_dict[action_address] + + def subscribe(self, event_name, event, notif_cb, subscribe_cb, error_cb): + event_address = str(uuid1()) + self.event_dict[event_name] = event_address + self.event_cb_dict[event_name] = notif_cb + self._event_subscribed_cb_list.append(subscribe_cb) + self._subscribe_error_cb_list.append(error_cb) + + def unsubscribe(self, address): + for (event_name, other_event) in self.event_dict.values(): + if event == othet_event: + del self.event_dict[event_name] + break class MockProbeMgrMultiAddons(object): """ -- cgit v0.9.1