Esempio n. 1
0
def init():
    auxiliary.install(aux_types.AUX_TYPE_ENTITY, "inventory", InventoryAux)
    command.add_command("inventory", inventory_command)
    command.add_command("fit", fit_command)
    command.add_command("unfit", unfit_command)
    command.add_command("test.add_active_warp_scanner", test_add_active_warp_scanner_command)
    hook.add(hook_types.REMOVE_MOBILE, clear_inventory_hook)
Esempio n. 2
0
 def setUp(self):
     UnitTestCase.setUp(self)
     self.hook_star_system_reset = mock.MagicMock()
     self.hook_star_system_reset.__name__ = 'hook_star_system_reset'
     hook.add(hook_types.STAR_SYSTEM_RESET, self.hook_star_system_reset)
     self.star_system = StarSystem()
     self.star_system.reset_interval = 10
Esempio n. 3
0
 def setUp(self):
     session.init()
     self.open_brain_hook = mock.MagicMock()
     self.open_brain_hook.__name__ = "open_brain_hook"
     self.close_brain_hook = mock.MagicMock()
     self.close_brain_hook.__name__ = "close_brain_hook"
     hook.add(hook.HOOK_OPEN_BRAIN, self.open_brain_hook)
     hook.add(hook.HOOK_CLOSE_BRAIN, self.close_brain_hook)
Esempio n. 4
0
    def test_run_catches_exceptions_in_hook_functions(self):
        def raiser(name):
            raise Exception()

        hook.add(self.name, raiser)
        try:
            hook.run(self.name)
        except Exception:
            self.fail("hook.run must catch all exceptions in hook functions.")
Esempio n. 5
0
 def test_run_does_not_call_functions_of_other_hook_types(self):
     func1 = mock.MagicMock()
     func1.__name__ = "func1"
     func2 = mock.MagicMock()
     func2.__name__ = "func2"
     hook.add(self.name, func1)
     hook.add("other", func2)
     hook.run(self.name)
     func1.assert_called_once_with(self.name)
     self.assertEqual(func2.call_count, 0)
Esempio n. 6
0
 def test_run_calls_all_functions_for_given_hook_type(self):
     func1 = mock.MagicMock()
     func1.__name__ = "func1"
     func2 = mock.MagicMock()
     func2.__name__ = "func2"
     hook.add(self.name, func1)
     hook.add(self.name, func2)
     hook.run(self.name)
     func1.assert_called_once_with(self.name)
     func2.assert_called_once_with(self.name)
Esempio n. 7
0
def init():
    hook.add(hook.HOOK_OPEN_BRAIN, open_brain_hook)
    hook.add(hook.HOOK_CLOSE_BRAIN, close_brain_hook)
Esempio n. 8
0
def init(eng, env):
    global engine, environment
    engine = eng
    environment = env
    hook.add(hook.HOOK_SHUTDOWN, shutdown_hook)
Esempio n. 9
0
 def test_run_passes_arguments_to_hook_functions(self):
     func = mock.MagicMock()
     func.__name__ = "hook"
     hook.add(self.name, func)
     hook.run(self.name, "foo", "bar", baz="omg")
     func.assert_called_once_with(self.name, "foo", "bar", baz="omg")
Esempio n. 10
0
def init():
    auxiliary.install(aux_types.AUX_TYPE_ENTITY, "warp", WarpAux)
    hook.add(hook_types.CELESTIAL_EXIT, clear_warp_scanner)
    hook.add(hook_types.STAR_SYSTEM_EXIT, clear_warp_scanner)