Skip to content

Commit 8f7d7d2

Browse files
author
Faustas
committed
tests and documentation wip
1 parent 74ee6fd commit 8f7d7d2

15 files changed

+430
-6
lines changed

test/conftest.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def mock_get(target, response_file=None):
5151
return data
5252

5353
@staticmethod
54-
def __put_post_callback(request, target, data, ignore_data_field=False, empty_payload=False):
54+
def __put_patch_post_callback(request, target, data, ignore_data_field=False, empty_payload=False):
5555
data_field = target.split("/")[0]
5656

5757
if not empty_payload:
@@ -69,7 +69,7 @@ def mock_post(target, empty_content=False, ignore_data_field=False, empty_payloa
6969
def callback(request):
7070
if not empty_content:
7171
data = json.loads(Mock.read_from_file(target + '_post.json'))
72-
return Mock.__put_post_callback(request, target, data, ignore_data_field, empty_payload)
72+
return Mock.__put_patch_post_callback(request, target, data, ignore_data_field, empty_payload)
7373
else:
7474
return(200, {}, '{}')
7575

@@ -82,13 +82,25 @@ def mock_put(target, ignore_data_field=False, empty_payload=False, call_api=True
8282
data = json.loads(Mock.read_from_file(target + '.json'))
8383

8484
def callback(request):
85-
return Mock.__put_post_callback(request, target, data, ignore_data_field, empty_payload)
85+
return Mock.__put_patch_post_callback(request, target, data, ignore_data_field, empty_payload)
8686

8787
url = Mock.base_url + '/' + target if call_api else target
8888
responses.add_callback(responses.PUT, url,
8989
callback=callback,
9090
content_type='application/json')
9191

92+
@staticmethod
93+
def mock_patch(target, ignore_data_field=False, empty_payload=False, call_api=True):
94+
data = json.loads(Mock.read_from_file(target + '.json'))
95+
96+
def callback(request):
97+
return Mock.__put_patch_post_callback(request, target, data, ignore_data_field, empty_payload)
98+
99+
url = Mock.base_url + '/' + target if call_api else target
100+
responses.add_callback(responses.PATCH, url,
101+
callback=callback,
102+
content_type='application/json')
103+
92104
@staticmethod
93105
def mock_delete(target):
94106
responses.add(responses.DELETE, Mock.base_url + '/' + target,

test/json_data/host.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"hosts": {
3+
"host": [
4+
{
5+
"id": 7653311107,
6+
"description": "My Host #1",
7+
"zone": "private-zone-id",
8+
"windows_enabled": "no",
9+
"stats": {
10+
"stat": [
11+
{
12+
"name": "cpu_idle",
13+
"timestamp": "2019-08-09T12:46:57Z",
14+
"value": 95.2
15+
},
16+
{
17+
"name": "memory_free",
18+
"timestamp": "2019-08-09T12:46:57Z",
19+
"value": 102
20+
}
21+
]
22+
}
23+
},
24+
{
25+
"id": 8055964291,
26+
"description": "My Host #2",
27+
"zone": "private-zone-id",
28+
"windows_enabled": "no",
29+
"stats": {
30+
"stat": [
31+
{
32+
"name": "cpu_idle",
33+
"timestamp": "2019-08-09T12:46:57Z",
34+
"value": 80.1
35+
},
36+
{
37+
"name": "memory_free",
38+
"timestamp": "2019-08-09T12:46:57Z",
39+
"value": 61
40+
}
41+
]
42+
}
43+
}
44+
]
45+
}
46+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"host": {
3+
"id": 7653311107,
4+
"description": "My Host #1",
5+
"zone": "private-zone-id",
6+
"windows_enabled": "no",
7+
"stats": {
8+
"stat": [
9+
{
10+
"name": "cpu_idle",
11+
"timestamp": "2019-08-09T12:46:57Z",
12+
"value": 95.2
13+
},
14+
{
15+
"name": "memory_free",
16+
"timestamp": "2019-08-09T12:46:57Z",
17+
"value": 102
18+
}
19+
]
20+
}
21+
}
22+
}

test/json_data/network.json

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
{
2+
"networks":
3+
{
4+
"network":
5+
[
6+
{
7+
"ip_networks":
8+
{
9+
"ip_network":
10+
[
11+
{
12+
"address": "94.237.8.0/22",
13+
"dhcp": "yes",
14+
"dhcp_default_route": "yes",
15+
"dhcp_dns": ["94.237.127.9", "94.237.40.9"],
16+
"family": "IPv4",
17+
"gateway": "94.237.8.1"}]},
18+
"name": "Public 94.237.8.0/22",
19+
"type": "public",
20+
"uuid": "03000000-0000-4000-8044-000000000000",
21+
"zone": "fi-hel2"
22+
},
23+
{
24+
"ip_networks":
25+
{
26+
"ip_network":
27+
[
28+
{
29+
"address": "10.6.0.0/22",
30+
"dhcp": "yes",
31+
"dhcp_default_route": "no",
32+
"dhcp_routes": ["10.0.0.0/8"],
33+
"family": "IPv4",
34+
"gateway": "10.6.0.1"}]},
35+
"name": "Private 10.6.0.0/22",
36+
"type": "utility",
37+
"uuid": "03000000-0000-4000-8045-000000000000",
38+
"zone": "fi-hel2"
39+
},
40+
{
41+
"ip_networks":
42+
{
43+
"ip_network":
44+
[
45+
{
46+
"address": "2a04:3545:1000:720::/64",
47+
"dhcp": "yes",
48+
"dhcp_default_route": "yes",
49+
"dhcp_dns": ["2a04:3540:53::1", "2a04:3544:53::1"],
50+
"family": "IPv6",
51+
"gateway": "2a04:3545:1000:720::1"}]},
52+
"name": "Public 2a04:3545:1000:720::/64",
53+
"servers":
54+
{
55+
"server":
56+
[
57+
{
58+
"title": "centos-1cpu-1gb-fi-hel2",
59+
"uuid": "00c0ee31-de2f-4c89-87b6-0d7d69c749a7"}]},
60+
"type": "public",
61+
"uuid": "03000000-0000-4000-8046-000000000000",
62+
"zone": "fi-hel2"
63+
},
64+
{
65+
"ip_networks":
66+
{
67+
"ip_network":
68+
[
69+
{
70+
"address": "94.237.12.0/22",
71+
"dhcp": "yes",
72+
"dhcp_default_route": "yes",
73+
"dhcp_dns": ["94.237.127.9", "94.237.40.9"],
74+
"family": "IPv4", "gateway": "94.237.12.1"}]},
75+
"name": "Public 94.237.12.0/22",
76+
"type": "public",
77+
"uuid": "03000000-0000-4000-8095-000000000000",
78+
"zone": "fi-hel2"
79+
},
80+
{
81+
"ip_networks":
82+
{
83+
"ip_network":
84+
[
85+
{
86+
"address": "10.6.4.0/22",
87+
"dhcp": "yes",
88+
"dhcp_default_route": "no",
89+
"dhcp_routes": ["10.0.0.0/8"],
90+
"family": "IPv4",
91+
"gateway": "10.6.4.1"}]},
92+
"name": "Private 10.6.4.0/22",
93+
"type": "utility",
94+
"uuid": "03000000-0000-4000-8096-000000000000",
95+
"zone": "fi-hel2"
96+
},
97+
{
98+
"ip_networks":
99+
{
100+
"ip_network":
101+
[
102+
{
103+
"address": "94.237.104.0/22",
104+
"dhcp": "yes",
105+
"dhcp_default_route": "yes",
106+
"dhcp_dns": ["94.237.127.9", "94.237.40.9"],
107+
"family": "IPv4",
108+
"gateway": "94.237.104.1"}]},
109+
"name": "Public fi-hel2 94.237.104.0/22",
110+
"servers":
111+
{
112+
"server":
113+
[
114+
{
115+
"title": "centos-1cpu-1gb-fi-hel2",
116+
"uuid": "00c0ee31-de2f-4c89-87b6-0d7d69c749a7"}]},
117+
"type": "public",
118+
"uuid":
119+
"031457f4-0f8c-483c-96f2-eccede02909c",
120+
"zone": "fi-hel2"
121+
},
122+
{
123+
"ip_networks":
124+
{
125+
"ip_network":
126+
[
127+
{
128+
"address": "10.6.0.0/22",
129+
"dhcp": "yes",
130+
"dhcp_default_route": "no",
131+
"dhcp_routes": ["10.0.0.0/8"],
132+
"family": "IPv4",
133+
"gateway": "10.6.0.1"}]},
134+
"name": "Private 10.6.0.0/22",
135+
"router": "04cad61f-baae-4019-8740-a840acd68319",
136+
"servers":
137+
{
138+
"server":
139+
[
140+
{
141+
"title": "centos-1cpu-1gb-fi-hel2",
142+
"uuid": "00c0ee31-de2f-4c89-87b6-0d7d69c749a7"
143+
}
144+
]
145+
},
146+
"type": "utility",
147+
"uuid": "03a0020f-896b-4453-913c-e236b8e639d6",
148+
"zone": "fi-hel2"}]}}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"network":
3+
{
4+
"ip_networks":
5+
{
6+
"ip_network":
7+
[
8+
{
9+
"address": "80.69.172.0/22",
10+
"dhcp": "yes",
11+
"dhcp_default_route": "yes",
12+
"dhcp_dns": ["94.237.127.9", "94.237.40.9"],
13+
"family": "IPv4", "gateway": "80.69.172.1"}]},
14+
"name": "Public 80.69.172.0/22",
15+
"type": "public",
16+
"uuid": "03000000-0000-4000-8001-000000000000",
17+
"zone": "fi-hel1"
18+
}
19+
}

test/json_data/router.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"routers": {
3+
"router": [
4+
{
5+
"attached_networks": {
6+
"network": [
7+
{
8+
"uuid": "03b34bc2-5adf-4fc4-8c44-83f869058f5a"}]},
9+
"name": "Utility network router for zone fi-hel1",
10+
"type": "service",
11+
"uuid": "04b65b2e-7c4b-465c-a24c-e1b47987f09b"
12+
},
13+
{
14+
"attached_networks": {
15+
"network": [
16+
{
17+
"uuid": "03a0020f-896b-4453-913c-e236b8e639d6"}]},
18+
"name": "Utility network router for zone fi-hel2",
19+
"type": "service",
20+
"uuid": "04cad61f-baae-4019-8740-a840acd68319"
21+
}
22+
]
23+
}
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"router":
3+
{
4+
"attached_networks": {"network": []},
5+
"name": "test router",
6+
"type": "normal",
7+
"uuid": "04da7f97-dc03-4df0-868f-239f304ba72f"
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"router":
3+
{
4+
"attached_networks": {"network": []},
5+
"name": "test router modify",
6+
"type": "normal",
7+
"uuid": "04da7f97-dc03-4df0-868f-239f304ba72f"
8+
}
9+
}

test/json_data/router_post.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"router":
3+
{
4+
"attached_networks":
5+
{
6+
"network": []},
7+
"name": "test router",
8+
"type": "normal",
9+
"uuid": "04da7f97-dc03-4df0-868f-239f304ba72f"
10+
}
11+
}

test/json_data/storage_public.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030
}
3131
]
3232
}
33-
}
33+
}

0 commit comments

Comments
 (0)