Skip to content

Commit 7e08f33

Browse files
committed
test: test_loader_workspace_enter
1 parent 2b11045 commit 7e08f33

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

tests/test_workspacebuilder.py

+68
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
"""Test for tmuxp workspacebuilder."""
22
import os
33
import pathlib
4+
import textwrap
5+
import time
46

57
import pytest
68

79
import kaptan
810

11+
import libtmux
912
from libtmux import Window
1013
from libtmux.common import has_gte_version
1114
from libtmux.test import retry, temp_session
@@ -869,3 +872,68 @@ def test_find_current_active_pane(server, monkeypatch):
869872
builder = WorkspaceBuilder(sconf=sconfig, server=server)
870873

871874
assert builder.find_current_attached_session() == second_session
875+
876+
877+
@pytest.mark.parametrize(
878+
"yaml,output,should_see",
879+
[
880+
[
881+
textwrap.dedent(
882+
"""
883+
session_name: sampleconfi
884+
windows:
885+
- panes:
886+
- shell_command:
887+
- echo "___$((1 + 3))___"
888+
enter: false
889+
"""
890+
),
891+
"___4___",
892+
False,
893+
],
894+
[
895+
textwrap.dedent(
896+
"""
897+
session_name: sampleconfi
898+
windows:
899+
- panes:
900+
- shell_command:
901+
- echo "___$((1 + 3))___"
902+
"""
903+
),
904+
"___4___",
905+
True,
906+
],
907+
],
908+
)
909+
def test_load_workspace_enter(
910+
tmp_path: pathlib.Path,
911+
server: libtmux.Server,
912+
monkeypatch: pytest.MonkeyPatch,
913+
yaml,
914+
output,
915+
should_see,
916+
):
917+
yaml_config = tmp_path / "simple.yaml"
918+
yaml_config.write_text(
919+
yaml,
920+
encoding="utf-8",
921+
)
922+
sconfig = kaptan.Kaptan(handler="yaml")
923+
sconfig = sconfig.import_config(str(yaml_config)).get()
924+
sconfig = config.expand(sconfig)
925+
sconfig = config.trickle(sconfig)
926+
builder = WorkspaceBuilder(sconf=sconfig, server=server)
927+
builder.build()
928+
929+
time.sleep(1)
930+
931+
session = builder.session
932+
pane = session.attached_pane
933+
934+
captured_pane = "\n".join(pane.capture_pane())
935+
936+
if should_see:
937+
assert output in captured_pane
938+
else:
939+
assert output not in captured_pane

0 commit comments

Comments
 (0)