Skip to content

Commit 592746d

Browse files
committed
test(workspacebuilder): Sleep in command
1 parent 68c43ee commit 592746d

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
@@ -1021,3 +1021,71 @@ def test_load_workspace_enter(
10211021
assert output in captured_pane
10221022
else:
10231023
assert output not in captured_pane
1024+
1025+
1026+
@pytest.mark.parametrize(
1027+
"yaml,output",
1028+
[
1029+
[
1030+
textwrap.dedent(
1031+
"""
1032+
session_name: Should not execute
1033+
windows:
1034+
- panes:
1035+
- shell_command: echo "___$((1 + 3))___"
1036+
sleep: 2
1037+
"""
1038+
),
1039+
"___4___",
1040+
],
1041+
[
1042+
textwrap.dedent(
1043+
"""
1044+
session_name: Should not execute
1045+
windows:
1046+
- panes:
1047+
- shell_command:
1048+
- echo "___$((1 + 3))___"
1049+
sleep: 2
1050+
"""
1051+
),
1052+
"___4___",
1053+
],
1054+
],
1055+
ids=[
1056+
"pane_sleep_3_shortform",
1057+
"pane_sleep_3_longform",
1058+
],
1059+
)
1060+
def test_load_workspace_sleep(
1061+
tmp_path: pathlib.Path,
1062+
server: libtmux.Server,
1063+
monkeypatch: pytest.MonkeyPatch,
1064+
yaml,
1065+
output,
1066+
):
1067+
yaml_config = tmp_path / "simple.yaml"
1068+
yaml_config.write_text(
1069+
yaml,
1070+
encoding="utf-8",
1071+
)
1072+
sconfig = kaptan.Kaptan(handler="yaml")
1073+
sconfig = sconfig.import_config(str(yaml_config)).get()
1074+
sconfig = config.expand(sconfig)
1075+
sconfig = config.trickle(sconfig)
1076+
builder = WorkspaceBuilder(sconf=sconfig, server=server)
1077+
builder.build()
1078+
1079+
t = time.process_time()
1080+
1081+
time.sleep(1)
1082+
session = builder.session
1083+
pane = session.attached_pane
1084+
1085+
while (time.process_time() - t) * 1000 < 2:
1086+
captured_pane = "\n".join(pane.capture_pane())
1087+
1088+
assert output not in captured_pane
1089+
time.sleep(0.1)
1090+
captured_pane = "\n".join(pane.capture_pane())
1091+
assert output in captured_pane

0 commit comments

Comments
 (0)