Esempio n. 1
0
def test_plugin_system_on_window_create_multiple_windows(session):
    config_plugins = test_utils.read_config_file(
        "workspacebuilder/plugin_owc_multiple_windows.yaml")

    sconfig = kaptan.Kaptan(handler="yaml")
    sconfig = sconfig.import_config(config_plugins).get()
    sconfig = config.expand(sconfig)

    builder = WorkspaceBuilder(sconf=sconfig, plugins=load_plugins(sconfig))
    assert len(builder.plugins) > 0

    builder.build(session=session)

    proc = session.cmd("list-windows", "-F", "'#W'")
    assert "'plugin_test_owc_mw'" in proc.stdout
    assert "'plugin_test_owc_mw_2'" in proc.stdout
Esempio n. 2
0
def test_plugin_system_after_window_finished(monkeypatch_plugin_test_packages,
                                             session):
    config_plugins = test_utils.read_config_file(
        "workspacebuilder/plugin_awf.yaml")

    sconfig = kaptan.Kaptan(handler="yaml")
    sconfig = sconfig.import_config(config_plugins).get()
    sconfig = config.expand(sconfig)

    builder = WorkspaceBuilder(sconf=sconfig, plugins=load_plugins(sconfig))
    assert len(builder.plugins) > 0

    builder.build(session=session)

    proc = session.cmd("display-message", "-p", "'#W'")
    assert proc.stdout[0] == "'plugin_test_awf'"
Esempio n. 3
0
def test_load_plugins(monkeypatch_plugin_test_packages):
    from tmuxp_test_plugin_bwb.plugin import PluginBeforeWorkspaceBuilder

    plugins_config = test_utils.read_config_file(
        "workspacebuilder/plugin_bwb.yaml")

    sconfig = kaptan.Kaptan(handler="yaml")
    sconfig = sconfig.import_config(plugins_config).get()
    sconfig = config.expand(sconfig)

    plugins = load_plugins(sconfig)

    assert len(plugins) == 1

    test_plugin_class_types = [
        PluginBeforeWorkspaceBuilder().__class__,
    ]
    for plugin in plugins:
        assert plugin.__class__ in test_plugin_class_types
Esempio n. 4
0
def test_reattach_plugins(monkeypatch_plugin_test_packages, server):
    config_plugins = test_utils.read_config_file(
        "workspacebuilder/plugin_r.yaml")

    sconfig = kaptan.Kaptan(handler="yaml")
    sconfig = sconfig.import_config(config_plugins).get()
    sconfig = config.expand(sconfig)

    # open it detached
    builder = WorkspaceBuilder(sconf=sconfig,
                               plugins=load_plugins(sconfig),
                               server=server)
    builder.build()

    try:
        _reattach(builder)
    except libtmux.exc.LibTmuxException:
        pass

    proc = builder.session.cmd("display-message", "-p", "'#S'")

    assert proc.stdout[0] == "'plugin_test_r'"
Esempio n. 5
0
def test_plugin_system_multiple_plugins(monkeypatch_plugin_test_packages,
                                        session):
    config_plugins = test_utils.read_config_file(
        "workspacebuilder/plugin_multiple_plugins.yaml")

    sconfig = kaptan.Kaptan(handler="yaml")
    sconfig = sconfig.import_config(config_plugins).get()
    sconfig = config.expand(sconfig)

    builder = WorkspaceBuilder(sconf=sconfig, plugins=load_plugins(sconfig))
    assert len(builder.plugins) > 0

    builder.build(session=session)

    # Drop through to the before_script plugin hook
    proc = session.cmd("display-message", "-p", "'#S'")
    assert proc.stdout[0] == "'plugin_test_bwb'"

    # Drop through to the after_window_finished. This won't succeed
    # unless on_window_create succeeds because of how the test plugin
    # override methods are currently written
    proc = session.cmd("display-message", "-p", "'#W'")
    assert proc.stdout[0] == "'mp_test_awf'"