Skip to content

Commit 1bd9674

Browse files
committed
add vscode settings to facilitate easier testing
add additional test using column names with spaces
1 parent 79d34c7 commit 1bd9674

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"python.analysis.extraPaths": [
3+
"./defog_utils"
4+
],
5+
"python.testing.pytestArgs": [
6+
"tests"
7+
],
8+
"python.testing.unittestEnabled": false,
9+
"python.testing.pytestEnabled": true,
10+
}

tests/test_utils_db.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,77 @@ def test_mk_create_table_ddl(self):
5151
");\n"
5252
)
5353
self.assertEqual(mk_create_table_ddl(table_name, columns), expected_output)
54+
55+
def test_mk_create_table_ddl_spaces(self):
56+
table_name = "table1"
57+
columns = [
58+
{
59+
"data_type": "text",
60+
"column_name": "Invoice Number",
61+
"column_description": "Unique identifier for each invoice"
62+
},
63+
{
64+
"data_type": "text",
65+
"column_name": "Invoice Date",
66+
"column_description": "Date when the invoice was issued"
67+
},
68+
{
69+
"data_type": "text",
70+
"column_name": "Sales Order#",
71+
"column_description": "Sales order number associated with the invoice"
72+
},
73+
{
74+
"data_type": "text",
75+
"column_name": "Customer Name",
76+
"column_description": "Name of the customer who made the purchase"
77+
},
78+
{
79+
"data_type": "int",
80+
"column_name": "Total with out GST",
81+
"column_description": "Total amount of the invoice without including GST"
82+
},
83+
{
84+
"data_type": "int",
85+
"column_name": "Total",
86+
"column_description": "Total amount of the invoice including GST"
87+
},
88+
{
89+
"data_type": "text",
90+
"column_name": "Status",
91+
"column_description": "Current status of the invoice"
92+
},
93+
{
94+
"data_type": "text",
95+
"column_name": "Salesperson Name",
96+
"column_description": "Name of the salesperson who handled the sale"
97+
},
98+
{
99+
"data_type": "text",
100+
"column_name": "Account Type",
101+
"column_description": "Type of account associated with the invoice"
102+
},
103+
{
104+
"data_type": "text",
105+
"column_name": "Item Category",
106+
"column_description": "Category of the item purchased"
107+
}
108+
]
109+
expected_output = (
110+
"CREATE TABLE table1 (\n"
111+
" \"Invoice Number\" text, --Unique identifier for each invoice\n"
112+
" \"Invoice Date\" text, --Date when the invoice was issued\n"
113+
" \"Sales Order#\" text, --Sales order number associated with the invoice\n"
114+
" \"Customer Name\" text, --Name of the customer who made the purchase\n"
115+
" \"Total with out GST\" integer, --Total amount of the invoice without including GST\n"
116+
" Total integer, --Total amount of the invoice including GST\n"
117+
" Status text, --Current status of the invoice\n"
118+
" \"Salesperson Name\" text, --Name of the salesperson who handled the sale\n"
119+
" \"Account Type\" text, --Type of account associated with the invoice\n"
120+
" \"Item Category\" text --Category of the item purchased\n"
121+
");\n"
122+
)
123+
self.assertEqual(mk_create_table_ddl(table_name, columns), expected_output)
124+
54125

55126

56127
class TestMkCreateDDL(unittest.TestCase):

0 commit comments

Comments
 (0)