Exemple #1
0
def test_register_hook_not_kolibri_plugin():
    try:
        hooks.register_hook(Hook)
        pytest.fail(
            "Allowed a hook defined outside of a kolibri_plugin module to be registered"
        )
    except RuntimeError:
        pass
Exemple #2
0
def test_register_multiple_hook_single_hook(valid_single_hook):
    valid_single_hook = hooks.register_hook(valid_single_hook)
    valid_single_hook.add_hook_to_registries()

    class OtherSingleHook(SingleHookAbstract):
        pass

    OtherSingleHook.__module__ = "test.kolibri_plugin"
    try:
        OtherSingleHook = hooks.register_hook(OtherSingleHook)
        OtherSingleHook.add_hook_to_registries()
        pytest.fail(
            "Allowed a hook single instance hook to be registered more than once"
        )
    except RuntimeError:
        pass
Exemple #3
0
def test_registered_hooks(valid_hook):
    valid_hook = hooks.register_hook(valid_hook)
    valid_hook.add_hook_to_registries()
    hook = valid_hook()
    assert hook in HookAbstract.registered_hooks
    assert len(list(HookAbstract.registered_hooks)) == 1
Exemple #4
0
def test_get_hook(valid_hook):
    valid_hook = hooks.register_hook(valid_hook)
    valid_hook.add_hook_to_registries()
    hook = valid_hook()
    assert HookAbstract.get_hook(hook.unique_id) is hook
Exemple #5
0
def test_singleton_hook(valid_hook):
    valid_hook = hooks.register_hook(valid_hook)
    assert valid_hook() is valid_hook()
Exemple #6
0
def test_register_hook_single_hook(valid_single_hook):
    hooks.register_hook(valid_single_hook)
Exemple #7
0
def test_register_hook_kolibri_plugin(valid_hook):
    hooks.register_hook(valid_hook)
Exemple #8
0
 def setUp(self):
     super(KolibriTagNavigationTestCase, self).setUp()
     Hook.__module__ = "test.kolibri_plugin"
     self.test_hook = register_hook(Hook)()