real-ladybug 0.0.1.dev1__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of real-ladybug might be problematic. Click here for more details.

Files changed (114) hide show
  1. real_ladybug/__init__.py +83 -0
  2. real_ladybug/_lbug.cp312-win_amd64.pyd +0 -0
  3. real_ladybug/_lbug.exp +0 -0
  4. real_ladybug/_lbug.lib +0 -0
  5. real_ladybug/async_connection.py +226 -0
  6. real_ladybug/connection.py +323 -0
  7. real_ladybug/constants.py +7 -0
  8. real_ladybug/database.py +307 -0
  9. real_ladybug/prepared_statement.py +51 -0
  10. real_ladybug/py.typed +0 -0
  11. real_ladybug/query_result.py +511 -0
  12. real_ladybug/torch_geometric_feature_store.py +185 -0
  13. real_ladybug/torch_geometric_graph_store.py +131 -0
  14. real_ladybug/torch_geometric_result_converter.py +282 -0
  15. real_ladybug/types.py +39 -0
  16. real_ladybug-0.0.1.dev1.dist-info/METADATA +88 -0
  17. real_ladybug-0.0.1.dev1.dist-info/RECORD +114 -0
  18. real_ladybug-0.0.1.dev1.dist-info/WHEEL +5 -0
  19. real_ladybug-0.0.1.dev1.dist-info/licenses/LICENSE +21 -0
  20. real_ladybug-0.0.1.dev1.dist-info/top_level.txt +3 -0
  21. real_ladybug-0.0.1.dev1.dist-info/zip-safe +1 -0
  22. real_ladybug-source/scripts/antlr4/hash.py +2 -0
  23. real_ladybug-source/scripts/antlr4/keywordhandler.py +47 -0
  24. real_ladybug-source/scripts/collect-extensions.py +68 -0
  25. real_ladybug-source/scripts/collect-single-file-header.py +126 -0
  26. real_ladybug-source/scripts/export-dbs.py +101 -0
  27. real_ladybug-source/scripts/export-import-test.py +345 -0
  28. real_ladybug-source/scripts/extension/purge-beta.py +34 -0
  29. real_ladybug-source/scripts/generate-cpp-docs/collect_files.py +122 -0
  30. real_ladybug-source/scripts/generate-tinysnb.py +34 -0
  31. real_ladybug-source/scripts/get-clangd-diagnostics.py +233 -0
  32. real_ladybug-source/scripts/migrate-lbug-db.py +308 -0
  33. real_ladybug-source/scripts/multiplatform-test-helper/collect-results.py +71 -0
  34. real_ladybug-source/scripts/multiplatform-test-helper/notify-discord.py +68 -0
  35. real_ladybug-source/scripts/pip-package/package_tar.py +90 -0
  36. real_ladybug-source/scripts/pip-package/setup.py +130 -0
  37. real_ladybug-source/scripts/run-clang-format.py +408 -0
  38. real_ladybug-source/scripts/setup-extension-repo.py +67 -0
  39. real_ladybug-source/scripts/test-simsimd-dispatch.py +45 -0
  40. real_ladybug-source/scripts/update-nightly-build-version.py +81 -0
  41. real_ladybug-source/third_party/brotli/scripts/dictionary/step-01-download-rfc.py +16 -0
  42. real_ladybug-source/third_party/brotli/scripts/dictionary/step-02-rfc-to-bin.py +34 -0
  43. real_ladybug-source/third_party/brotli/scripts/dictionary/step-03-validate-bin.py +35 -0
  44. real_ladybug-source/third_party/brotli/scripts/dictionary/step-04-generate-java-literals.py +85 -0
  45. real_ladybug-source/third_party/pybind11/tools/codespell_ignore_lines_from_errors.py +35 -0
  46. real_ladybug-source/third_party/pybind11/tools/libsize.py +36 -0
  47. real_ladybug-source/third_party/pybind11/tools/make_changelog.py +63 -0
  48. real_ladybug-source/tools/python_api/build/real_ladybug/__init__.py +83 -0
  49. real_ladybug-source/tools/python_api/build/real_ladybug/async_connection.py +226 -0
  50. real_ladybug-source/tools/python_api/build/real_ladybug/connection.py +323 -0
  51. real_ladybug-source/tools/python_api/build/real_ladybug/constants.py +7 -0
  52. real_ladybug-source/tools/python_api/build/real_ladybug/database.py +307 -0
  53. real_ladybug-source/tools/python_api/build/real_ladybug/prepared_statement.py +51 -0
  54. real_ladybug-source/tools/python_api/build/real_ladybug/py.typed +0 -0
  55. real_ladybug-source/tools/python_api/build/real_ladybug/query_result.py +511 -0
  56. real_ladybug-source/tools/python_api/build/real_ladybug/torch_geometric_feature_store.py +185 -0
  57. real_ladybug-source/tools/python_api/build/real_ladybug/torch_geometric_graph_store.py +131 -0
  58. real_ladybug-source/tools/python_api/build/real_ladybug/torch_geometric_result_converter.py +282 -0
  59. real_ladybug-source/tools/python_api/build/real_ladybug/types.py +39 -0
  60. real_ladybug-source/tools/python_api/src_py/__init__.py +83 -0
  61. real_ladybug-source/tools/python_api/src_py/async_connection.py +226 -0
  62. real_ladybug-source/tools/python_api/src_py/connection.py +323 -0
  63. real_ladybug-source/tools/python_api/src_py/constants.py +7 -0
  64. real_ladybug-source/tools/python_api/src_py/database.py +307 -0
  65. real_ladybug-source/tools/python_api/src_py/prepared_statement.py +51 -0
  66. real_ladybug-source/tools/python_api/src_py/py.typed +0 -0
  67. real_ladybug-source/tools/python_api/src_py/query_result.py +511 -0
  68. real_ladybug-source/tools/python_api/src_py/torch_geometric_feature_store.py +185 -0
  69. real_ladybug-source/tools/python_api/src_py/torch_geometric_graph_store.py +131 -0
  70. real_ladybug-source/tools/python_api/src_py/torch_geometric_result_converter.py +282 -0
  71. real_ladybug-source/tools/python_api/src_py/types.py +39 -0
  72. real_ladybug-source/tools/python_api/test/conftest.py +230 -0
  73. real_ladybug-source/tools/python_api/test/disabled_test_extension.py +73 -0
  74. real_ladybug-source/tools/python_api/test/ground_truth.py +430 -0
  75. real_ladybug-source/tools/python_api/test/test_arrow.py +694 -0
  76. real_ladybug-source/tools/python_api/test/test_async_connection.py +159 -0
  77. real_ladybug-source/tools/python_api/test/test_blob_parameter.py +145 -0
  78. real_ladybug-source/tools/python_api/test/test_connection.py +49 -0
  79. real_ladybug-source/tools/python_api/test/test_database.py +234 -0
  80. real_ladybug-source/tools/python_api/test/test_datatype.py +372 -0
  81. real_ladybug-source/tools/python_api/test/test_df.py +564 -0
  82. real_ladybug-source/tools/python_api/test/test_dict.py +112 -0
  83. real_ladybug-source/tools/python_api/test/test_exception.py +54 -0
  84. real_ladybug-source/tools/python_api/test/test_fsm.py +227 -0
  85. real_ladybug-source/tools/python_api/test/test_get_header.py +49 -0
  86. real_ladybug-source/tools/python_api/test/test_helper.py +8 -0
  87. real_ladybug-source/tools/python_api/test/test_issue.py +147 -0
  88. real_ladybug-source/tools/python_api/test/test_iteration.py +96 -0
  89. real_ladybug-source/tools/python_api/test/test_networkx.py +437 -0
  90. real_ladybug-source/tools/python_api/test/test_parameter.py +340 -0
  91. real_ladybug-source/tools/python_api/test/test_prepared_statement.py +117 -0
  92. real_ladybug-source/tools/python_api/test/test_query_result.py +54 -0
  93. real_ladybug-source/tools/python_api/test/test_query_result_close.py +44 -0
  94. real_ladybug-source/tools/python_api/test/test_scan_pandas.py +676 -0
  95. real_ladybug-source/tools/python_api/test/test_scan_pandas_pyarrow.py +714 -0
  96. real_ladybug-source/tools/python_api/test/test_scan_polars.py +165 -0
  97. real_ladybug-source/tools/python_api/test/test_scan_pyarrow.py +167 -0
  98. real_ladybug-source/tools/python_api/test/test_timeout.py +11 -0
  99. real_ladybug-source/tools/python_api/test/test_torch_geometric.py +640 -0
  100. real_ladybug-source/tools/python_api/test/test_torch_geometric_remote_backend.py +111 -0
  101. real_ladybug-source/tools/python_api/test/test_udf.py +207 -0
  102. real_ladybug-source/tools/python_api/test/test_version.py +6 -0
  103. real_ladybug-source/tools/python_api/test/test_wal.py +80 -0
  104. real_ladybug-source/tools/python_api/test/type_aliases.py +10 -0
  105. real_ladybug-source/tools/rust_api/update_version.py +47 -0
  106. real_ladybug-source/tools/shell/test/conftest.py +218 -0
  107. real_ladybug-source/tools/shell/test/test_helper.py +60 -0
  108. real_ladybug-source/tools/shell/test/test_shell_basics.py +325 -0
  109. real_ladybug-source/tools/shell/test/test_shell_commands.py +656 -0
  110. real_ladybug-source/tools/shell/test/test_shell_control_edit.py +438 -0
  111. real_ladybug-source/tools/shell/test/test_shell_control_search.py +468 -0
  112. real_ladybug-source/tools/shell/test/test_shell_esc_edit.py +232 -0
  113. real_ladybug-source/tools/shell/test/test_shell_esc_search.py +162 -0
  114. real_ladybug-source/tools/shell/test/test_shell_flags.py +645 -0
@@ -0,0 +1,656 @@
1
+ from conftest import ShellTest
2
+
3
+
4
+ def test_help(temp_db) -> None:
5
+ test = ShellTest().add_argument(temp_db).statement(":help")
6
+ result = test.run()
7
+ result.check_stdout(
8
+ [
9
+ " :help get command list",
10
+ " :clear clear shell",
11
+ " :quit exit from shell",
12
+ " :max_rows [max_rows] set maximum number of rows for display (default: 20)",
13
+ " :max_width [max_width] set maximum width in characters for display",
14
+ " :mode [mode] set output mode (default: box)",
15
+ " :stats [on|off] toggle query stats on or off",
16
+ " :multiline set multiline mode (default)",
17
+ " :singleline set singleline mode",
18
+ " :highlight [on|off] toggle syntax highlighting on or off",
19
+ " :render_errors [on|off] toggle error highlighting on or off",
20
+ " :render_completion [on|off] toggle completion highlighting on or off",
21
+ "",
22
+ " Note: you can change and see several system configurations, such as num-threads, ",
23
+ " timeout, and progress_bar using Cypher CALL statements.",
24
+ " e.g. CALL THREADS=5; or CALL current_setting('threads') return *;",
25
+ " See: \x1b]8;;https://docs.ladybugdb.com/cypher/configuration\x1b\\https://docs.ladybugdb.com/cypher/configuration\x1b]8;;\x1b\\",
26
+ ],
27
+ )
28
+
29
+
30
+ def test_clear(temp_db) -> None:
31
+ test = ShellTest().add_argument(temp_db).statement(":clear")
32
+ result = test.run()
33
+ result.check_stdout("\x1b[H\x1b[2J")
34
+
35
+
36
+ def test_quit(temp_db) -> None:
37
+ test = (
38
+ ShellTest()
39
+ .add_argument(temp_db)
40
+ .statement(":quit")
41
+ .statement("RETURN RANGE(0,10) AS a;")
42
+ )
43
+ result = test.run()
44
+ # check to make sure the return query did not execute
45
+ result.check_not_stdout("[0,1,2,3,4,5,6,7,8,9,10]")
46
+
47
+
48
+ def test_max_rows(temp_db, csv_path) -> None:
49
+ # test all rows shown
50
+ test = (
51
+ ShellTest()
52
+ .add_argument(temp_db)
53
+ .statement(":max_rows 40")
54
+ .statement(f'LOAD FROM "{csv_path}" (HEADER=true) RETURN id;')
55
+ )
56
+ result = test.run()
57
+ result.check_stdout("(21 tuples)")
58
+ result.check_not_stdout(
59
+ [
60
+ "\u2502 \u00b7 \u2502",
61
+ "\u2502 \u00b7 \u2502",
62
+ "\u2502 \u00b7 \u2502",
63
+ ]
64
+ )
65
+
66
+ # test 1 row shown
67
+ test = (
68
+ ShellTest()
69
+ .add_argument(temp_db)
70
+ .statement(":max_rows 1")
71
+ .statement(f'LOAD FROM "{csv_path}" (HEADER=true) RETURN id;')
72
+ )
73
+ result = test.run()
74
+ result.check_stdout("(21 tuples, 1 shown)")
75
+ result.check_stdout(
76
+ [
77
+ "\u2502 \u00b7 \u2502",
78
+ "\u2502 \u00b7 \u2502",
79
+ "\u2502 \u00b7 \u2502",
80
+ ]
81
+ )
82
+
83
+ # test setting back to default
84
+ test = (
85
+ ShellTest()
86
+ .add_argument(temp_db)
87
+ .statement(":max_rows 0")
88
+ .statement(f'LOAD FROM "{csv_path}" (HEADER=true) RETURN id;')
89
+ )
90
+ result = test.run()
91
+ result.check_stdout("(21 tuples, 20 shown)")
92
+ result.check_stdout(
93
+ [
94
+ "\u2502 \u00b7 \u2502",
95
+ "\u2502 \u00b7 \u2502",
96
+ "\u2502 \u00b7 \u2502",
97
+ ]
98
+ )
99
+
100
+
101
+ def test_max_width(temp_db, csv_path) -> None:
102
+ # test all columns shown
103
+ test = (
104
+ ShellTest()
105
+ .add_argument(temp_db)
106
+ .statement(":max_width 400")
107
+ .statement(f'LOAD FROM "{csv_path}" (HEADER=true) RETURN *;')
108
+ )
109
+ result = test.run()
110
+ result.check_stdout("id")
111
+ result.check_stdout("fname")
112
+ result.check_stdout("Gender")
113
+ result.check_stdout("ISStudent")
114
+ result.check_stdout("isWorker")
115
+ result.check_stdout("age")
116
+ result.check_stdout("eyeSight")
117
+ result.check_stdout("birthdate")
118
+ result.check_stdout("registerTime")
119
+ result.check_stdout("lastJobDuration")
120
+ result.check_stdout("workedHours")
121
+ result.check_stdout("usedNames")
122
+ result.check_stdout("courseScoresPerTerm")
123
+ result.check_not_stdout("\u2502 ... \u2502")
124
+ result.check_stdout("(13 columns)")
125
+
126
+ # test 2 columns shown
127
+ test = (
128
+ ShellTest()
129
+ .add_argument(temp_db)
130
+ .statement(":max_width 44")
131
+ .statement(f'LOAD FROM "{csv_path}" (HEADER=true) RETURN *;')
132
+ )
133
+ result = test.run()
134
+ result.check_stdout("id")
135
+ result.check_not_stdout("fname")
136
+ result.check_not_stdout("Gender")
137
+ result.check_not_stdout("ISStudent")
138
+ result.check_not_stdout("isWorker")
139
+ result.check_not_stdout("\u2502 age \u2502")
140
+ result.check_not_stdout("eyeSight")
141
+ result.check_not_stdout("birthdate")
142
+ result.check_not_stdout("registerTime")
143
+ result.check_not_stdout("lastJobDuration")
144
+ result.check_not_stdout("workedHours")
145
+ result.check_not_stdout("usedNames")
146
+ result.check_stdout("\u2502 ... \u2502")
147
+ result.check_stdout("courseScoresPerTerm")
148
+ result.check_stdout("(13 columns, 2 shown)")
149
+
150
+ # test too small to display (back to terminal width)
151
+ test = (
152
+ ShellTest()
153
+ .add_argument(temp_db)
154
+ .statement(":max_width 2")
155
+ .statement(f'LOAD FROM "{csv_path}" (HEADER=true) RETURN *;')
156
+ )
157
+ result = test.run()
158
+ # terminal width when running test is 80
159
+ result.check_stdout("id")
160
+ result.check_stdout("fname")
161
+ result.check_stdout("Gender")
162
+ result.check_not_stdout("ISStudent")
163
+ result.check_not_stdout("isWorker")
164
+ result.check_not_stdout("\u2502 age \u2502")
165
+ result.check_not_stdout("eyeSight")
166
+ result.check_not_stdout("birthdate")
167
+ result.check_not_stdout("registerTime")
168
+ result.check_not_stdout("lastJobDuration")
169
+ result.check_not_stdout("workedHours")
170
+ result.check_not_stdout("usedNames")
171
+ result.check_stdout("\u2502 ... \u2502")
172
+ result.check_stdout("courseScoresPerTerm")
173
+ result.check_stdout("(13 columns, 4 shown)")
174
+
175
+ # test result tuples unaffected by width
176
+ test = (
177
+ ShellTest()
178
+ .add_argument(temp_db)
179
+ .statement(":max_width 2")
180
+ .statement(
181
+ "CREATE NODE TABLE LANGUAGE_CODE(alpha2 STRING, English STRING, PRIMARY KEY (alpha2));",
182
+ )
183
+ )
184
+ result = test.run()
185
+ # terminal width when running test is 80
186
+ result.check_stdout("\u2502 Table LANGUAGE_CODE has been created. \u2502")
187
+ result.check_not_stdout("\u2502 ... \u2502")
188
+ result.check_stdout("(1 column)")
189
+
190
+
191
+ def output_mode_verification(result) -> None:
192
+ result.check_stdout(
193
+ [
194
+ "Available output modes:",
195
+ " box (default): Tables using unicode box-drawing characters",
196
+ " column: Output in columns",
197
+ " csv: Comma-separated values",
198
+ " html: HTML table",
199
+ " json: Results in a JSON array",
200
+ " jsonlines: Results in a NDJSON format",
201
+ " latex: LaTeX tabular environment code",
202
+ " line: One value per line",
203
+ ' list: Values delimited by "|"',
204
+ " markdown: Markdown table",
205
+ " table: Tables using ASCII characters",
206
+ " tsv: Tab-separated values",
207
+ " trash: No output",
208
+ ],
209
+ )
210
+
211
+
212
+ def test_set_mode(temp_db) -> None:
213
+ # test default mode
214
+ test = (
215
+ ShellTest()
216
+ .add_argument(temp_db)
217
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
218
+ )
219
+ result = test.run()
220
+ result.check_stdout("\u2502 a \u2502 b \u2502")
221
+ result.check_stdout("\u2502 Databases Rule \u2502 lbug is cool \u2502")
222
+
223
+ # test column mode
224
+ test = (
225
+ ShellTest()
226
+ .add_argument(temp_db)
227
+ .statement(":mode column")
228
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
229
+ )
230
+ result = test.run()
231
+ result.check_stdout("a b")
232
+ result.check_stdout("Databases Rule lbug is cool")
233
+
234
+ # test csv mode
235
+ test = (
236
+ ShellTest()
237
+ .add_argument(temp_db)
238
+ .statement(":mode csv")
239
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
240
+ )
241
+ result = test.run()
242
+ result.check_stdout("a,b")
243
+ result.check_stdout("Databases Rule,lbug is cool")
244
+
245
+ # test csv escaping
246
+ test = (
247
+ ShellTest()
248
+ .add_argument(temp_db)
249
+ .statement(":mode csv")
250
+ .statement(
251
+ 'RETURN "This is a \\"test\\", with commas, \\"quotes\\", and\nnewlines.";'
252
+ )
253
+ )
254
+ result = test.run()
255
+ result.check_stdout('"This is a ""test"", with commas, ""quotes"", and\nnewlines."')
256
+
257
+ # test box mode
258
+ test = (
259
+ ShellTest()
260
+ .add_argument(temp_db)
261
+ # box is default so need to switch to another mode first
262
+ .statement(":mode csv")
263
+ .statement(":mode box")
264
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
265
+ )
266
+ result = test.run()
267
+ result.check_stdout("\u2502 a \u2502 b \u2502")
268
+ result.check_stdout("\u2502 Databases Rule \u2502 lbug is cool \u2502")
269
+
270
+ # test html mode
271
+ test = (
272
+ ShellTest()
273
+ .add_argument(temp_db)
274
+ .statement(":mode html")
275
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
276
+ )
277
+ result = test.run()
278
+ result.check_stdout("<table>")
279
+ result.check_stdout("<tr>")
280
+ result.check_stdout("<th>a</th><th>b</th>")
281
+ result.check_stdout("</tr>")
282
+ result.check_stdout("<tr>")
283
+ result.check_stdout("<td>Databases Rule</td><td>lbug is cool</td>")
284
+ result.check_stdout("</tr>")
285
+ result.check_stdout("</table>")
286
+
287
+ # test html escaping
288
+ test = (
289
+ ShellTest()
290
+ .add_argument(temp_db)
291
+ .statement(":mode html")
292
+ .statement(
293
+ 'RETURN "This is a <test> & \\"example\\" with \'special\' characters." AS a;'
294
+ )
295
+ )
296
+ result = test.run()
297
+ result.check_stdout("<table>")
298
+ result.check_stdout("<tr>")
299
+ result.check_stdout("<th>a</th>")
300
+ result.check_stdout("</tr>")
301
+ result.check_stdout("<tr>")
302
+ result.check_stdout(
303
+ "<td>This is a &lt;test&gt; &amp; &quot;example&quot; with &apos;special&apos; characters.</td>"
304
+ )
305
+ result.check_stdout("</tr>")
306
+ result.check_stdout("</table>")
307
+
308
+ # test json mode
309
+ test = (
310
+ ShellTest()
311
+ .add_argument(temp_db)
312
+ .statement(":mode json")
313
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
314
+ )
315
+ result = test.run()
316
+ result.check_stdout('[\n{"a":"Databases Rule","b":"lbug is cool"}\n]')
317
+
318
+ # test json escaping
319
+ test = (
320
+ ShellTest()
321
+ .add_argument(temp_db)
322
+ .statement(":mode json")
323
+ .statement(
324
+ 'RETURN "This is a \\"test\\" with backslashes \\\\, newlines\n, and tabs \t." AS a;'
325
+ )
326
+ )
327
+ result = test.run()
328
+ result.check_stdout(
329
+ '[\n{"a":"This is a \\"test\\" with backslashes \\\\, newlines\\n, and tabs \\t."}\n]'
330
+ )
331
+
332
+ # test jsonlines mode
333
+ test = (
334
+ ShellTest()
335
+ .add_argument(temp_db)
336
+ .statement(":mode jsonlines")
337
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
338
+ )
339
+ result = test.run()
340
+ result.check_stdout('{"a":"Databases Rule","b":"lbug is cool"}')
341
+
342
+ # test jsonlines escaping
343
+ test = (
344
+ ShellTest()
345
+ .add_argument(temp_db)
346
+ .statement(":mode jsonlines")
347
+ .statement(
348
+ 'RETURN "This is a \\"test\\" with backslashes \\\\, newlines\n, and tabs \t." AS a;'
349
+ )
350
+ )
351
+ result = test.run()
352
+ result.check_stdout(
353
+ '{"a":"This is a \\"test\\" with backslashes \\\\, newlines\\n, and tabs \\t."}'
354
+ )
355
+
356
+ # test latex mode
357
+ test = (
358
+ ShellTest()
359
+ .add_argument(temp_db)
360
+ .statement(":mode latex")
361
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
362
+ )
363
+ result = test.run()
364
+ result.check_stdout("\\begin{tabular}{ll}")
365
+ result.check_stdout("\\hline")
366
+ result.check_stdout("a&b\\\\")
367
+ result.check_stdout("\\hline")
368
+ result.check_stdout("Databases Rule&lbug is cool\\\\")
369
+ result.check_stdout("\\hline")
370
+ result.check_stdout("\\end{tabular}")
371
+
372
+ # test latex escaping
373
+ test = (
374
+ ShellTest()
375
+ .add_argument(temp_db)
376
+ .statement(":mode latex")
377
+ .statement(
378
+ 'RETURN "This is a test with special characters: %, $, &, #, _, {, }, ~, ^, \\\\, <, and >." AS a;'
379
+ )
380
+ )
381
+ result = test.run()
382
+ result.check_stdout("\\begin{tabular}{l}")
383
+ result.check_stdout("\\hline")
384
+ result.check_stdout("a\\\\")
385
+ result.check_stdout("\\hline")
386
+ result.check_stdout(
387
+ "This is a test with special characters: \\%, \\$, \\&, \\#, \\_, \\{, \\}, \\textasciitilde{}, \\textasciicircum{}, \\textbackslash{}, \\textless{}, and \\textgreater{}.\\\\"
388
+ )
389
+ result.check_stdout("\\hline")
390
+ result.check_stdout("\\end{tabular}")
391
+
392
+ # test line mode
393
+ test = (
394
+ ShellTest()
395
+ .add_argument(temp_db)
396
+ .statement(":mode line")
397
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
398
+ )
399
+ result = test.run()
400
+ result.check_stdout("a = Databases Rule")
401
+ result.check_stdout("b = lbug is cool")
402
+
403
+ # test list mode
404
+ test = (
405
+ ShellTest()
406
+ .add_argument(temp_db)
407
+ .statement(":mode list")
408
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
409
+ )
410
+ result = test.run()
411
+ result.check_stdout("a|b")
412
+ result.check_stdout("Databases Rule|lbug is cool")
413
+
414
+ # test list escaping
415
+ test = (
416
+ ShellTest()
417
+ .add_argument(temp_db)
418
+ .statement(":mode tsv")
419
+ .statement(
420
+ 'RETURN "This is a \\"test\\", with vertical bars |, \\"quotes\\", and\nnewlines.";'
421
+ )
422
+ )
423
+ result = test.run()
424
+ result.check_stdout(
425
+ '"This is a ""test"", with vertical bars |, ""quotes"", and\nnewlines."'
426
+ )
427
+
428
+ # test markdown mode
429
+ test = (
430
+ ShellTest()
431
+ .add_argument(temp_db)
432
+ .statement(":mode markdown")
433
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
434
+ )
435
+ result = test.run()
436
+ result.check_stdout("| a | b |")
437
+ result.check_stdout("| Databases Rule | lbug is cool |")
438
+
439
+ # test table mode
440
+ test = (
441
+ ShellTest()
442
+ .add_argument(temp_db)
443
+ .statement(":mode table")
444
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
445
+ )
446
+ result = test.run()
447
+ result.check_stdout("| a | b |")
448
+ result.check_stdout("| Databases Rule | lbug is cool |")
449
+
450
+ # test tsv mode
451
+ test = (
452
+ ShellTest()
453
+ .add_argument(temp_db)
454
+ .statement(":mode tsv")
455
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
456
+ )
457
+ result = test.run()
458
+ result.check_stdout("a\tb")
459
+ result.check_stdout("Databases Rule\tlbug is cool")
460
+
461
+ # test tsv escaping
462
+ test = (
463
+ ShellTest()
464
+ .add_argument(temp_db)
465
+ .statement(":mode tsv")
466
+ .statement(
467
+ 'RETURN "This is a \\"test\\", with tabs \t, \\"quotes\\", and\nnewlines.";'
468
+ )
469
+ )
470
+ result = test.run()
471
+ result.check_stdout(
472
+ '"This is a ""test"", with tabs \t, ""quotes"", and\nnewlines."'
473
+ )
474
+
475
+ # test trash mode
476
+ test = (
477
+ ShellTest()
478
+ .add_argument(temp_db)
479
+ .statement(":mode trash")
480
+ .statement("RETURN RANGE(0, 10) AS a;")
481
+ )
482
+ result = test.run()
483
+ result.check_not_stdout("[0,1,2,3,4,5,6,7,8,9,10]")
484
+
485
+ # test mode info
486
+ test = (
487
+ ShellTest()
488
+ .add_argument(temp_db)
489
+ .statement(":mode invalid")
490
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
491
+ )
492
+ result = test.run()
493
+ output_mode_verification(result)
494
+
495
+ # test invalid mode
496
+ test = (
497
+ ShellTest()
498
+ .add_argument(temp_db)
499
+ .statement(":mode invalid")
500
+ .statement('RETURN "Databases Rule" AS a, "lbug is cool" AS b;')
501
+ )
502
+ result = test.run()
503
+ result.check_stdout("Cannot parse 'invalid' as output mode.")
504
+ output_mode_verification(result)
505
+
506
+
507
+ def test_stats(temp_db) -> None:
508
+ # test stats default
509
+ test = ShellTest().add_argument(temp_db).statement('RETURN "Databases Rule" AS a;')
510
+ result = test.run()
511
+ result.check_stdout("(1 tuple)")
512
+ result.check_stdout("(1 column)")
513
+ result.check_stdout("Time: ")
514
+
515
+ # test stats off
516
+ test = (
517
+ ShellTest()
518
+ .add_argument(temp_db)
519
+ .statement(":stats off")
520
+ .statement('RETURN "Databases Rule" AS a;')
521
+ )
522
+ result = test.run()
523
+ result.check_not_stdout("(1 tuple)")
524
+ result.check_not_stdout("(1 column)")
525
+ result.check_not_stdout("Time: ")
526
+
527
+ # test stats on
528
+ test = (
529
+ ShellTest()
530
+ .add_argument(temp_db)
531
+ .statement(":stats on")
532
+ .statement('RETURN "Databases Rule" AS a;')
533
+ )
534
+ result = test.run()
535
+ result.check_stdout("(1 tuple)")
536
+ result.check_stdout("(1 column)")
537
+ result.check_stdout("Time: ")
538
+
539
+ # test stats invalid
540
+ test = (
541
+ ShellTest()
542
+ .add_argument(temp_db)
543
+ .statement(":stats invalid")
544
+ .statement('RETURN "Databases Rule" AS a;')
545
+ )
546
+ result = test.run()
547
+ result.check_stdout("Cannot parse 'invalid' to toggle stats. Expect 'on' or 'off'.")
548
+
549
+
550
+ def test_multiline(temp_db) -> None:
551
+ test = (
552
+ ShellTest()
553
+ .add_argument(temp_db)
554
+ .statement(":multiline")
555
+ .statement("RETURN")
556
+ .statement('"databases rule"')
557
+ .statement("AS")
558
+ .statement("a")
559
+ .statement(";")
560
+ )
561
+ result = test.run()
562
+ result.check_stdout("\u2502 databases rule \u2502")
563
+
564
+ # test no truncation
565
+ test = ShellTest().add_argument(temp_db).statement("a" * 400 + ";")
566
+ result = test.run()
567
+ result.check_stdout("a" * 400)
568
+
569
+
570
+ def test_singleline(temp_db) -> None:
571
+ test = (
572
+ ShellTest()
573
+ .add_argument(temp_db)
574
+ .statement(":multiline")
575
+ .statement(":singleline")
576
+ .statement("RETURN")
577
+ .statement('"databases rule"')
578
+ .statement("AS")
579
+ .statement("a")
580
+ .statement(";")
581
+ )
582
+ result = test.run()
583
+ result.check_stdout("\u2502 databases rule \u2502")
584
+
585
+ # test truncation
586
+ test = ShellTest().add_argument(temp_db).statement("a" * 400 + ";")
587
+ result = test.run()
588
+ result.check_stdout("a" * 80)
589
+
590
+
591
+ def test_highlight(temp_db) -> None:
592
+ test = ShellTest().add_argument(temp_db).statement(":highlight off")
593
+ result = test.run()
594
+ result.check_stdout("disabled syntax highlighting")
595
+
596
+ test = ShellTest().add_argument(temp_db).statement(":highlight on")
597
+ result = test.run()
598
+ result.check_stdout("enabled syntax highlighting")
599
+
600
+ test = ShellTest().add_argument(temp_db).statement(":highlight o")
601
+ result = test.run()
602
+ result.check_stdout(
603
+ "Cannot parse 'o' to toggle highlighting. Expect 'on' or 'off'."
604
+ )
605
+
606
+
607
+ def test_render_errors(temp_db) -> None:
608
+ test = ShellTest().add_argument(temp_db).statement(":render_errors off")
609
+ result = test.run()
610
+ result.check_stdout("disabled error highlighting")
611
+
612
+ test = ShellTest().add_argument(temp_db).statement(":render_errors on")
613
+ result = test.run()
614
+ result.check_stdout("enabled error highlighting")
615
+
616
+ test = ShellTest().add_argument(temp_db).statement(":render_errors o")
617
+ result = test.run()
618
+ result.check_stdout(
619
+ "Cannot parse 'o' to toggle error highlighting. Expect 'on' or 'off'."
620
+ )
621
+
622
+
623
+ def test_completion_highlighting(temp_db) -> None:
624
+ test = ShellTest().add_argument(temp_db).statement(":render_completion off")
625
+ result = test.run()
626
+ result.check_stdout("disabled completion highlighting")
627
+
628
+ test = ShellTest().add_argument(temp_db).statement(":render_completion on")
629
+ result = test.run()
630
+ result.check_stdout("enabled completion highlighting")
631
+
632
+ test = ShellTest().add_argument(temp_db).statement(":render_completion o")
633
+ result = test.run()
634
+ result.check_stdout(
635
+ "Cannot parse 'o' to toggle completion highlighting. Expect 'on' or 'off'."
636
+ )
637
+
638
+
639
+ def test_bad_command(temp_db) -> None:
640
+ test = (
641
+ ShellTest()
642
+ .add_argument(temp_db)
643
+ .statement(":maxrows")
644
+ .statement(":quiy")
645
+ .statement("clearr;")
646
+ )
647
+ result = test.run()
648
+ result.check_stdout(
649
+ 'Error: Unknown command: ":maxrows". Enter ":help" for help',
650
+ )
651
+ result.check_stdout('Did you mean: ":max_rows"?')
652
+ result.check_stdout('Error: Unknown command: ":quiy". Enter ":help" for help')
653
+ result.check_stdout('Did you mean: ":quit"?')
654
+ result.check_stdout(
655
+ '"clearr;" is not a valid Cypher query. Did you mean to issue a CLI command, e.g., ":clear"?',
656
+ )