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

Class ShellTest

tools/shell/test/conftest.py:56–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54
55
56class ShellTest:
57 def __init__(self) -> None:
58 self.shell = LBUG_EXEC_PATH
59 self.arguments = [self.shell]
60 self.statements: list[str] = []
61 self.input = None
62 self.output = None
63 self.environment = {}
64 self.shell_process = None
65
66 def add_argument(self, *args):
67 self.arguments.extend(args)
68 return self
69
70 def statement(self, stmt):
71 self.statements.append(stmt)
72 return self
73
74 def query(self, *stmts):
75 self.statements.extend(stmts)
76 return self
77
78 def input_file(self, file_path):
79 self.input = file_path
80 return self
81
82 def output_file(self, file_path):
83 self.output = file_path
84 return self
85
86 # Test Running methods
87
88 def get_command(self, cmd: str) -> list[str]:
89 command = self.arguments
90 if self.input:
91 command += [cmd]
92 return command
93
94 def get_input_data(self, cmd: str):
95 if self.input:
96 with open(self.input, "rb") as f:
97 input_data = f.read()
98 else:
99 input_data = bytearray(cmd, "utf8")
100 return input_data
101
102 def get_output_pipe(self):
103 output_pipe = subprocess.PIPE
104 if self.output:
105 output_pipe = open(self.output, "w+")
106 return output_pipe
107
108 def get_statements(self):
109 statements = []
110 for statement in self.statements:
111 statements.append(statement)
112 return "\n".join(statements)
113

Calls

no outgoing calls

Tested by 15

test_search_next_topFunction · 0.72
test_basicFunction · 0.72
test_rangeFunction · 0.72
test_nested_typesFunction · 0.72
test_invalid_castFunction · 0.72
test_multilineFunction · 0.72
test_row_truncationFunction · 0.72