-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_driver.py
72 lines (53 loc) · 1.76 KB
/
test_driver.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
#! Copyright (c) 2023 University of New Hampshire
#! SPDX-License-Identifier: MIT
import requests
def endpoint_to_url(endpoint):
return "http://0.0.0.0:5001" + endpoint
# returns a tuple of (status_code, response_body)
def do(method, endpoint, body=None):
url = endpoint_to_url(endpoint)
response = None
if body:
response = method(url, json = body)
else:
response = method(url)
response_body = None
try:
response_body = response.json()
except Exception as e:
print("endpoint did not give back json")
return (response.status_code, response_body)
def post(endpoint, body=None):
return do(requests.post, endpoint, body)
def get(endpoint, body=None):
return do(requests.get, endpoint, body)
class template(object):
def prefix():
return "/template"
class blobs(object):
def get_list():
return get(template.prefix() + "/list")
# returns id of the newly committed template
def commit(id: str):
pass
# returns uuid for a basic blob with one host of an arbitrary flavor (if flavor=None),
# that has not been committed yet
def basic_blob(flavor=None, hostname="host"):
pass
# returns a uuid for a basic template with one host of an arbitrary flavor
def basic_template():
blob_id = blobs.basic_blob()
template_id = blobs.commit(blob_id)
return template_id
class booking(object):
def prefix():
return "/booking"
def booking_with(template_id, for_user=42, credentials=[], cifile=""):
pass
class tests(object):
def basic_e2e():
tid = template.basic_template()
bid = booking.booking_with(tid)
def run_tests():
tests.basic_e2e()
run_tests()