MCPcopy Index your code
hub / github.com/dbcli/pgcli / test_output_sql_update

Function test_output_sql_update

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

Source from the content-addressed store, hash-verified

66
67
68def test_output_sql_update():
69 global formatter
70 formatter = TabularOutputFormatter
71 register_new_formatter(formatter)
72 data = [
73 [
74 1,
75 "Jackson",
76 "jackson_test@gmail.com",
77 "132454789",
78 "",
79 "2022-09-09 19:44:32.712343+08",
80 "2022-09-09 19:44:32.712343+08",
81 ]
82 ]
83 header = ["id", "name", "email", "phone", "description", "created_at", "updated_at"]
84 table_format = "sql-update"
85 kwargs = {
86 "column_types": [int, str, str, str, str, str, str],
87 "sep_title": "RECORD {n}",
88 "sep_character": "-",
89 "sep_length": (1, 25),
90 "missing_value": "<null>",
91 "integer_format": "",
92 "float_format": "",
93 "disable_numparse": True,
94 "preserve_whitespace": True,
95 "max_field_width": 500,
96 }
97 formatter.query = 'SELECT * FROM "user";'
98 output = adapter(data, header, table_format=table_format, **kwargs)
99 output_list = list(output)
100 print(output_list)
101 expected = [
102 'UPDATE "user" SET',
103 " \"name\" = 'Jackson'",
104 ", \"email\" = 'jackson_test@gmail.com'",
105 ", \"phone\" = '132454789'",
106 ", \"description\" = ''",
107 ", \"created_at\" = '2022-09-09 19:44:32.712343+08'",
108 ", \"updated_at\" = '2022-09-09 19:44:32.712343+08'",
109 "WHERE \"id\" = '1';",
110 ]
111 assert expected == output_list

Callers

nothing calls this directly

Calls 2

register_new_formatterFunction · 0.90
adapterFunction · 0.90

Tested by

no test coverage detected