MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / test_enter

Function test_enter

tools/shell/test/test_shell_control_edit.py:74–106  ·  view source on GitHub ↗
(temp_db, key, history_path, mode)

Source from the content-addressed store, hash-verified

72)
73@pytest.mark.parametrize("mode", [":multiline\n", ":singleline\n"])
74def test_enter(temp_db, key, history_path, mode) -> None:
75 test = (
76 ShellTest().add_argument(temp_db).add_argument("-p").add_argument(history_path)
77 )
78 test.start()
79 test.send_finished_statement(mode)
80 test.send_statement('RETURN "databases rule" AS a;')
81 test.send_finished_statement(key)
82 assert (
83 test.shell_process.expect_exact(["\u2502 databases rule \u2502", pexpect.EOF])
84 == 0
85 )
86 assert test.shell_process.expect_exact(["lbug", pexpect.EOF]) == 0
87
88 with open(os.path.join(history_path, "history.txt")) as f:
89 assert f.readline() == mode
90 assert f.readline() == 'RETURN "databases rule" AS a;\n'
91 deleteIfExists(os.path.join(history_path, "history.txt"))
92
93 # enter in multiline when not at the end of the line should not execute the query
94 test = (
95 ShellTest().add_argument(temp_db).add_argument("-p").add_argument(history_path)
96 )
97 test.start()
98 test.send_finished_statement(mode)
99 test.send_statement('RETURN "databases rule" AS a;\x1b[D\x1b[D\x1b[D')
100 test.send_finished_statement(key)
101 assert test.shell_process.expect_exact(["lbug", pexpect.EOF]) == 0
102
103 with open(os.path.join(history_path, "history.txt")) as f:
104 assert f.readline() == mode
105 assert f.readline() != 'RETURN "databases rule" AS a;\n'
106 deleteIfExists(os.path.join(history_path, "history.txt"))
107
108
109@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 7

ShellTestClass · 0.90
deleteIfExistsFunction · 0.90
add_argumentMethod · 0.80
send_statementMethod · 0.80
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected