-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
156 lines (118 loc) · 3.31 KB
/
test.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
146
147
148
149
150
151
152
153
154
155
156
import requests
import json
from dotenv import load_dotenv
import os
load_dotenv() # take environment variables from .env.
ID = 0
URL = "http://localhost:8080/api/v1/account"
TOKEN = "fkskfjsfkjsfs"
NAME = "Hello"
SPEC = "Some spec"
HASH = "284fsklfjs"
IDC = 0
def mock_create_account():
print("@mock_create_account")
global ID
account = {
"name": NAME,
"spec": SPEC,
"key" : HASH
};
response = requests.post(URL+"/?api_key="+TOKEN,json=account)
ID = 3
print("@mock_create_account [end]")
def mock_auth_account():
print("@mock_auth_account")
input_name = NAME
input_key = HASH
input_account = {
"name" : input_name,
"key" : input_key
};
response = requests.post(URL+"/auth?api_key="+TOKEN,json=input_account)
print(response.json())
print("@mock_auth_account [end]")
def mock_update_account():
print("@mock_update_account")
naccount = {
"spec" : "somethign new"
};
response = requests.put(URL+'/'+str(ID)+"?api_key="+TOKEN,json=naccount)
print(response.content)
print("@mock_update_account [end]")
def mock_get_all_accounts():
print("@mock_get_all_accounts")
response = requests.get(URL+"/?api_key="+TOKEN)
print(response.json())
print("@mock_get_all_accounts [end]")
def mock_create_config():
print("@mock_create_config")
global IDC
input_config = {
"name" : "somenameconfig",
"states" : [],
"intents": []
};
response = requests.post(URL+"/"+str(ID)+"/config?api_key="+TOKEN,json=input_config)
IDC = response.json()["id"]
print(response.json())
print("@mock_create_config [end]")
def mock_udpate_config():
print("mock_update_config")
global IDC
nstates = []
nchoices= []
nchoice = {
"name": "fksjfsj"
};
nchoices.append(nchoice)
nstate = {
"name" : "somestatename",
"answers": ["klsfj","isfsfks","fkjsfjs"],
"choices": nchoices
};
nstates.append(nstate)
input_config = {
"name" : "somenewnameconfig",
"states" : nstates
};
response = requests.put(URL+"/config/"+str(IDC)+"?api_key="+TOKEN,json=input_config)
print(response.content)
print("mock_update_config [end]")
def mock_config_delete():
print("@mock_config_delete")
global IDC
response = requests.delete(URL+"/config/"+str(IDC)+"?api_key="+TOKEN)
print(response.content)
print("@mock_config_delete [end]")
def mock_get_all_configs():
print("@mock_get_all_configs")
global ID
response = requests.get(URL+"/"+str(ID)+"/config?api_key="+TOKEN)
print(response.json())
print("@mock_get_all_configs [end]")
def mock_account_delete():
print("@mock_account_delete")
global ID
response = requests.delete(URL+"/"+str(ID)+"?api_key="+TOKEN)
print(response.content)
print("@mock_account_delete [end]")
if __name__ == "__main__":
mock_create_account()
print("\n")
mock_get_all_accounts()
print("\n")
mock_auth_account()
print("\n")
mock_update_account()
print("\n")
mock_create_config()
print("\n")
mock_udpate_config()
print("\n")
mock_get_all_configs()
print("\n")
mock_config_delete()
print("\n")
mock_account_delete()
print("\n")