Ejemplo n.º 1
0
    def test_cannot_register_for_unknown_phase(self):
        plugin = team.PluginDescriptor("unittest-plugin")
        hook = self.UnitTestHook(phase="this_is_an_unknown_install_phase")
        handler = team.BootstrapHookHandler(plugin, loader_class=self.UnitTestComponentLoader)

        handler.loader.registration_function = hook
        with pytest.raises(exceptions.SystemSetupError) as exc:
            handler.load()
        assert exc.value.args[0] == "Unknown bootstrap phase [this_is_an_unknown_install_phase]. Valid phases are: ['post_install']."
Ejemplo n.º 2
0
    def test_loads_module(self):
        plugin = team.PluginDescriptor("unittest-plugin")
        hook = self.UnitTestHook()
        handler = team.BootstrapHookHandler(plugin, loader_class=self.UnitTestComponentLoader)

        handler.loader.registration_function = hook
        handler.load()

        handler.invoke("post_install", variables={"increment": 4})

        # we registered our hook twice. Check that it has been called twice.
        assert hook.call_counter == 2 * 4
Ejemplo n.º 3
0
    def test_cannot_register_for_unknown_phase(self):
        plugin = team.PluginDescriptor("unittest-plugin")
        hook = BootstrapHookHandlerTests.UnitTestHook(
            phase="this_is_an_unknown_install_phase")
        handler = team.BootstrapHookHandler(
            plugin,
            loader_class=BootstrapHookHandlerTests.UnitTestComponentLoader)

        handler.loader.registration_function = hook
        with self.assertRaises(exceptions.SystemSetupError) as ctx:
            handler.load()
        self.assertEqual(
            "Unknown bootstrap phase [this_is_an_unknown_install_phase]. Valid phases are: ['post_install', 'post_launch'].",
            ctx.exception.args[0])