Skip to content

Commit

Permalink
add vscode settings to facilitate easier testing
Browse files Browse the repository at this point in the history
add additional test using column names with spaces
  • Loading branch information
wongjingping committed Aug 5, 2024
1 parent 79d34c7 commit 1bd9674
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"python.analysis.extraPaths": [
"./defog_utils"
],
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
}
71 changes: 71 additions & 0 deletions tests/test_utils_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,77 @@ def test_mk_create_table_ddl(self):
");\n"
)
self.assertEqual(mk_create_table_ddl(table_name, columns), expected_output)

def test_mk_create_table_ddl_spaces(self):
table_name = "table1"
columns = [
{
"data_type": "text",
"column_name": "Invoice Number",
"column_description": "Unique identifier for each invoice"
},
{
"data_type": "text",
"column_name": "Invoice Date",
"column_description": "Date when the invoice was issued"
},
{
"data_type": "text",
"column_name": "Sales Order#",
"column_description": "Sales order number associated with the invoice"
},
{
"data_type": "text",
"column_name": "Customer Name",
"column_description": "Name of the customer who made the purchase"
},
{
"data_type": "int",
"column_name": "Total with out GST",
"column_description": "Total amount of the invoice without including GST"
},
{
"data_type": "int",
"column_name": "Total",
"column_description": "Total amount of the invoice including GST"
},
{
"data_type": "text",
"column_name": "Status",
"column_description": "Current status of the invoice"
},
{
"data_type": "text",
"column_name": "Salesperson Name",
"column_description": "Name of the salesperson who handled the sale"
},
{
"data_type": "text",
"column_name": "Account Type",
"column_description": "Type of account associated with the invoice"
},
{
"data_type": "text",
"column_name": "Item Category",
"column_description": "Category of the item purchased"
}
]
expected_output = (
"CREATE TABLE table1 (\n"
" \"Invoice Number\" text, --Unique identifier for each invoice\n"
" \"Invoice Date\" text, --Date when the invoice was issued\n"
" \"Sales Order#\" text, --Sales order number associated with the invoice\n"
" \"Customer Name\" text, --Name of the customer who made the purchase\n"
" \"Total with out GST\" integer, --Total amount of the invoice without including GST\n"
" Total integer, --Total amount of the invoice including GST\n"
" Status text, --Current status of the invoice\n"
" \"Salesperson Name\" text, --Name of the salesperson who handled the sale\n"
" \"Account Type\" text, --Type of account associated with the invoice\n"
" \"Item Category\" text --Category of the item purchased\n"
");\n"
)
self.assertEqual(mk_create_table_ddl(table_name, columns), expected_output)



class TestMkCreateDDL(unittest.TestCase):
Expand Down

0 comments on commit 1bd9674

Please sign in to comment.