77
88import pytest
99
10+ import kaptan
11+
1012import click
1113from click .testing import CliRunner
1214
2022 is_pure_name ,
2123 load_workspace ,
2224 scan_config ,
23- load_plugins ,
25+ _reattach
2426)
27+ from tmuxp .workspacebuilder import WorkspaceBuilder
2528
2629from .fixtures ._util import curjoin , loadfixture
27- from tmuxp_test_plugin_bwb . plugin import PluginBeforeWorkspaceBuilder
30+
2831
2932def test_creates_config_dir_not_exists (tmpdir ):
3033 """cli.startup() creates config dir if not exists."""
@@ -268,18 +271,6 @@ def check_cmd(config_arg):
268271 assert 'config not found in config dir' in check_cmd ('moo' )
269272
270273
271- def test_load_plugins ():
272- session_config = curjoin ("workspacebuildter/plugin_bwb.yaml" )
273- plugins = load_plugins (session_config )
274- assert len (plugins ) == 1
275-
276- test_plugin_class_types = [
277- PluginBeforeWorkspaceBuilder ().__class__ ,
278- ]
279- for plugin in plugins :
280- assert plugin .__class__ in test_plugin_class_types
281-
282-
283274def test_load_workspace (server , monkeypatch ):
284275 # this is an implementation test. Since this testsuite may be ran within
285276 # a tmux session by the developer himself, delete the TMUX variable
@@ -966,3 +957,25 @@ def test_ls_cli(monkeypatch, tmpdir):
966957 runner = CliRunner ()
967958 cli_output = runner .invoke (command_ls ).output
968959 assert cli_output == '\n ' .join (stems ) + '\n '
960+
961+
962+ def test_reattach_plugins (server ):
963+ config_plugins = loadfixture ("workspacebuilder/plugin_r.yaml" )
964+
965+ sconfig = kaptan .Kaptan (handler = 'yaml' )
966+ sconfig = sconfig .import_config (config_plugins ).get ()
967+ sconfig = config .expand (sconfig )
968+
969+ # open it detached
970+ builder = WorkspaceBuilder (sconf = sconfig , server = server )
971+ builder .build ()
972+
973+ try :
974+ _reattach (builder )
975+ except libtmux .exc .LibTmuxException as error :
976+ pass
977+
978+
979+ proc = builder .session .cmd ('display-message' , '-p' , "'#S'" )
980+
981+ assert proc .stdout [0 ] == "'plugin_test_r'"
0 commit comments