MCPcopy
hub / github.com/dbcli/pgcli / test_output_sql_insert

Function test_output_sql_insert

tests/formatter/test_sqlformatter.py:27–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25
26
27def test_output_sql_insert():
28 global formatter
29 formatter = TabularOutputFormatter
30 register_new_formatter(formatter)
31 data = [
32 [
33 1,
34 "Jackson",
35 "jackson_test@gmail.com",
36 "132454789",
37 None,
38 "2022-09-09 19:44:32.712343+08",
39 "2022-09-09 19:44:32.712343+08",
40 ]
41 ]
42 header = ["id", "name", "email", "phone", "description", "created_at", "updated_at"]
43 table_format = "sql-insert"
44 kwargs = {
45 "column_types": [int, str, str, str, str, str, str],
46 "sep_title": "RECORD {n}",
47 "sep_character": "-",
48 "sep_length": (1, 25),
49 "missing_value": "<null>",
50 "integer_format": "",
51 "float_format": "",
52 "disable_numparse": True,
53 "preserve_whitespace": True,
54 "max_field_width": 500,
55 }
56 formatter.query = 'SELECT * FROM "user";'
57 output = adapter(data, header, table_format=table_format, **kwargs)
58 output_list = list(output)
59 expected = [
60 'INSERT INTO "user" ("id", "name", "email", "phone", "description", "created_at", "updated_at") VALUES',
61 " ('1', 'Jackson', 'jackson_test@gmail.com', '132454789', NULL, "
62 + "'2022-09-09 19:44:32.712343+08', '2022-09-09 19:44:32.712343+08')",
63 ";",
64 ]
65 assert expected == output_list
66
67
68def test_output_sql_update():

Callers

nothing calls this directly

Calls 2

register_new_formatterFunction · 0.90
adapterFunction · 0.90

Tested by

no test coverage detected