-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_graphql_server.py
145 lines (137 loc) · 5.8 KB
/
test_graphql_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
from unittest import TestCase
from core.GraphQLServer import GraphQLServer
import tempfile
import os
class TestGraphQLServer(TestCase):
def test_generate_graphql_server(self):
# _table_metadata = [
# {
# "table_name": "department",
# "columns": [
# {"field_type": "int", "field_name": "id"},
# {"field_type": "str", "field_name": "name"}
# ],
# "primary_key_fields": ["id"]
# },
# {
# "table_name": "employee",
# "columns": [
# {"field_type": "int", "field_name": "id"},
# {"field_type": "str", "field_name": "name"},
# {"field_type": "datetime", "field_name": "hired_on"},
# {"field_type": "int", "field_name": "department_id", "exclude_from_search": True}
# ],
# "primary_key_fields": ["id"],
# "foreign_key": {
# "parent_table_name": "department",
# "self_columns": ["department_id"],
# "parent_columns": ["id"]
# }
# }
# ]
_table_metadata = [
{
"table_name": "business_partner",
"columns": [
{"field_name": "partner_id", "field_type": "int"},
{"field_name": "partner_name", "field_type": "str"},
{"field_name": "partner_type", "field_type": "str"}
],
"primary_key_fields": ["partner_id"]
},
{
"table_name": "commodity",
"columns": [
{"field_name": "commodity_id", "field_type": "int"},
{"field_name": "commodity_code", "field_type": "str"},
{"field_name": "commodity_name", "field_type": "str"}
],
"primary_key_fields": ["commodity_id"]
},
{
"table_name": "inco_term",
"columns": [
{"field_name": "inco_term_id", "field_type": "int"},
{"field_name": "inco_term_code", "field_type": "str"}
],
"primary_key_fields": ["inco_term_id"]
},
{
"table_name": "inco_term_language",
"columns": [
{"field_name": "inco_term_id", "field_type": "int"},
{"field_name": "language_code", "field_type": "str"},
{"field_name": "inco_term_desc", "field_type": "str"}
],
"primary_key_fields": ["inco_term_id", "language_code"],
"foreign_key_fields": [
{
"parent_table_name": "inco_term",
"self_columns": ["inco_term_id"],
"parent_columns": ["inco_term_id"]
}
]
},
{
"table_name": "contract_header",
"columns": [
{"field_name": "contract_id", "field_type": "int"},
{"field_name": "contract_ref_no", "field_type": "str"},
{"field_name": "contract_type", "field_type": "str"},
{"field_name": "inco_term_id", "field_type": "str"},
{"field_name": "commodity_id", "field_type": "int"},
{"field_name": "partner_id", "field_type": "int"}
],
"primary_key_fields": ["contract_id"],
"foreign_key_fields": [
{
"parent_table_name": "business_partner",
"self_columns": ["partner_id"],
"parent_columns": ["partner_id"]
},
{
"parent_table_name": "commodity",
"self_columns": ["commodity_id"],
"parent_columns": ["commodity_id"]
},
{
"parent_table_name": "inco_term",
"self_columns": ["inco_term_id"],
"parent_columns": ["inco_term_id"]
}
]
},
{
"table_name": "contract_line_item",
"columns": [
{"field_name": "contract_id", "field_type": "int"},
{"field_name": "item_id", "field_type": "int"},
{"field_name": "delivery_start_date", "field_type": "date"},
{"field_name": "delivery_end_date", "field_type": "date"},
{"field_name": "open_quantity", "field_type": "int"},
{"field_name": "item_status", "field_type": "str"}
],
"primary_key_fields": ["contract_id", "item_id"],
"foreign_key_fields": [
{
"parent_table_name": "contract_header",
"self_columns": ["contract_id"],
"parent_columns": ["contract_id"]
}
]
}
]
# base_path = tempfile.gettempdir()
base_path = "C:/Temp/GraphQLPOC"
root_folder_name = "auto-graphql-demo"
graph_ql_server = GraphQLServer(
app_name="autoGraphqlDemo",
base_path=base_path,
root_folder_name=root_folder_name,
table_meta_data=_table_metadata
)
graph_ql_server.generate_graphql_server()
for root, d_names, f_names in os.walk(base_path + "/" + root_folder_name):
print(root, d_names, f_names)
test = TestGraphQLServer()
test.test_generate_graphql_server()