Revision 1b918ce3 snf-cyclades-app/synnefo/neutron/tests/api.py
b/snf-cyclades-app/synnefo/neutron/tests/api.py | ||
---|---|---|
42 | 42 |
|
43 | 43 |
def test_get_network(self): |
44 | 44 |
test_net = mf.NetworkFactory.create() |
45 |
url = join_urls(NETWORKS_URL, test_net.uuid)
|
|
45 |
url = join_urls(NETWORKS_URL, str(test_net.id))
|
|
46 | 46 |
response = self.get(url, user=test_net.userid) |
47 | 47 |
# validate response |
48 | 48 |
res = json.loads(response.content) |
... | ... | |
55 | 55 |
|
56 | 56 |
def test_get_deleted_network(self): |
57 | 57 |
test_net = mf.NetworkFactory.create() |
58 |
url = join_urls(NETWORKS_URL, test_net.uuid)
|
|
58 |
url = join_urls(NETWORKS_URL, str(test_net.id))
|
|
59 | 59 |
self.delete(url, user=test_net.userid) |
60 | 60 |
response = self.get(url, user=test_net.userid) |
61 | 61 |
self.assertEqual(response.status_code, 400) |
... | ... | |
68 | 68 |
def test_delete_network(self): |
69 | 69 |
test_net = mf.NetworkFactory.create() |
70 | 70 |
subnet = mf.SubnetFactory.create(network=test_net) |
71 |
url = join_urls(NETWORKS_URL, test_net.uuid)
|
|
71 |
url = join_urls(NETWORKS_URL, str(test_net.id))
|
|
72 | 72 |
response = self.delete(url, user=test_net.userid) |
73 | 73 |
self.assertEqual(response.status_code, 204) |
74 | 74 |
|
75 | 75 |
def test_delete_network_in_use(self): |
76 | 76 |
test_net = mf.NetworkFactory.create() |
77 | 77 |
test_iface = mf.NetworkInterfaceFactory.create(network=test_net) |
78 |
url = join_urls(NETWORKS_URL, test_net.uuid)
|
|
78 |
url = join_urls(NETWORKS_URL, str(test_net.id))
|
|
79 | 79 |
response = self.delete(url, user=test_net.userid) |
80 | 80 |
self.assertEqual(response.status_code, 409) |
81 | 81 |
|
... | ... | |
86 | 86 |
|
87 | 87 |
def test_put_network(self): |
88 | 88 |
test_net = mf.NetworkFactory.create() |
89 |
url = join_urls(NETWORKS_URL, test_net.uuid)
|
|
89 |
url = join_urls(NETWORKS_URL, str(test_net.id))
|
|
90 | 90 |
request = { |
91 | 91 |
"network": { |
92 | 92 |
"name": "new_name"} |
... | ... | |
97 | 97 |
|
98 | 98 |
def test_put_network_wrong_data(self): |
99 | 99 |
test_net = mf.NetworkFactory.create() |
100 |
url = join_urls(NETWORKS_URL, test_net.uuid)
|
|
100 |
url = join_urls(NETWORKS_URL, str(test_net.id))
|
|
101 | 101 |
request = { |
102 | 102 |
"network": { |
103 | 103 |
"wrong_field": "new_name"} |
... | ... | |
108 | 108 |
|
109 | 109 |
def test_put_no_data(self): |
110 | 110 |
test_net = mf.NetworkFactory.create() |
111 |
url = join_urls(NETWORKS_URL, test_net.uuid)
|
|
111 |
url = join_urls(NETWORKS_URL, str(test_net.id))
|
|
112 | 112 |
response = self.put(url, params="", user=test_net.userid) |
113 | 113 |
self.assertEqual(response.status_code, 400) |
114 | 114 |
|
... | ... | |
123 | 123 |
|
124 | 124 |
def test_get_port(self): |
125 | 125 |
nic = mf.NetworkInterfaceFactory.create() |
126 |
url = join_urls(PORTS_URL, nic.uuid)
|
|
126 |
url = join_urls(PORTS_URL, str(nic.id))
|
|
127 | 127 |
response = self.get(url, user=nic.network.userid) |
128 | 128 |
self.assertEqual(response.status_code, 200) |
129 | 129 |
|
130 | 130 |
def test_delete_port(self): |
131 | 131 |
nic = mf.NetworkInterfaceFactory.create(owner='vm') |
132 |
url = join_urls(PORTS_URL, nic.uuid)
|
|
132 |
url = join_urls(PORTS_URL, str(nic.id))
|
|
133 | 133 |
response = self.delete(url, user=nic.network.userid) |
134 | 134 |
self.assertEqual(response.status_code, 204) |
135 | 135 |
|
136 | 136 |
def test_update_port_name(self): |
137 | 137 |
nic = mf.NetworkInterfaceFactory.create(owner='vm') |
138 |
url = join_urls(PORTS_URL, nic.uuid)
|
|
138 |
url = join_urls(PORTS_URL, str(nic.id))
|
|
139 | 139 |
request = {'port': {"name": "test-name"}} |
140 | 140 |
response = self.put(url, params=json.dumps(request), |
141 | 141 |
user=nic.network.userid) |
... | ... | |
148 | 148 |
nic = mf.NetworkInterfaceFactory.create(owner='vm') |
149 | 149 |
nic.security_groups.add(sg1) |
150 | 150 |
nic.save() |
151 |
url = join_urls(PORTS_URL, nic.uuid)
|
|
151 |
url = join_urls(PORTS_URL, str(nic.id))
|
|
152 | 152 |
request = {'port': {"security_groups": ["123"]}} |
153 | 153 |
response = self.put(url, params=json.dumps(request), |
154 | 154 |
user=nic.network.userid) |
... | ... | |
161 | 161 |
nic = mf.NetworkInterfaceFactory.create(owner='vm') |
162 | 162 |
nic.security_groups.add(sg1) |
163 | 163 |
nic.save() |
164 |
url = join_urls(PORTS_URL, nic.uuid)
|
|
164 |
url = join_urls(PORTS_URL, str(nic.id))
|
|
165 | 165 |
request = {'port': {"security_groups": [str(sg2.id), str(sg3.id)]}} |
166 | 166 |
response = self.put(url, params=json.dumps(request), |
167 | 167 |
user=nic.network.userid) |
... | ... | |
190 | 190 |
request = { |
191 | 191 |
"port": { |
192 | 192 |
"name": "port1", |
193 |
"network_id": net.uuid,
|
|
193 |
"network_id": str(net.id),
|
|
194 | 194 |
"device_id": str(vm.id), |
195 | 195 |
"security_groups": [str(sg1.id), str(sg2.id)] |
196 | 196 |
} |
... | ... | |
226 | 226 |
"router": { |
227 | 227 |
"name": "test-router", |
228 | 228 |
"external_gateway_info": { |
229 |
"network_id": net.uuid
|
|
229 |
"network_id": str(net.id)
|
|
230 | 230 |
} |
231 | 231 |
} |
232 | 232 |
} |
... | ... | |
246 | 246 |
"router": { |
247 | 247 |
"name": "test-router", |
248 | 248 |
"external_gateway_info": { |
249 |
"network_id": fip.network.uuid,
|
|
249 |
"network_id": str(fip.network.id),
|
|
250 | 250 |
"floating_ip": str(fip.id)} |
251 | 251 |
} |
252 | 252 |
} |
... | ... | |
266 | 266 |
"router": { |
267 | 267 |
"name": "test-router", |
268 | 268 |
"external_gateway_info": { |
269 |
"network_id": net.uuid}
|
|
269 |
"network_id": str(net.id)}
|
|
270 | 270 |
} |
271 | 271 |
} |
272 | 272 |
response = self.post(ROUTERS_URL, params=json.dumps(request), |
... | ... | |
303 | 303 |
request = { |
304 | 304 |
"router": { |
305 | 305 |
"name": "new_name", |
306 |
"external_gateway_info": {"network_id": net.uuid}
|
|
306 |
"external_gateway_info": {"network_id": str(net.id)}
|
|
307 | 307 |
} |
308 | 308 |
} |
309 | 309 |
url = join_urls(ROUTERS_URL, str(router.id)) |
... | ... | |
311 | 311 |
user=router.userid) |
312 | 312 |
info = json.loads(response.content) |
313 | 313 |
self.assertEqual(info['router']['external_gateway_info']['network_id'], |
314 |
net.uuid)
|
|
314 |
str(net.id))
|
|
315 | 315 |
self.assertEqual(info['router']['name'], "new_name") |
316 | 316 |
|
317 | 317 |
def test_remove_interface_no_body(self): |
Also available in: Unified diff