Revision 2cd55da6 snf-cyclades-app/synnefo/api/test/floating_ips.py

b/snf-cyclades-app/synnefo/api/test/floating_ips.py
42 42
from mock import patch, Mock
43 43
from functools import partial
44 44

  
45
from synnefo.cyclades_settings import cyclades_services
46
from synnefo.lib.services import get_service_path
47
from synnefo.lib import join_urls
45 48

  
46
URL = "/api/v1.1/os-floating-ips"
49

  
50
compute_path = get_service_path(cyclades_services, "compute", version="v2.0")
51
URL = join_urls(compute_path, "os-floating-ips")
52
NETWORKS_URL = join_urls(compute_path, "networks")
53
SERVERS_URL = join_urls(compute_path, "servers")
47 54

  
48 55
FloatingIPPoolFactory = partial(NetworkFactory, public=True, deleted=False,
49 56
                                floating_ip_pool=True)
......
195 202
        # Also send a notification to remove the NIC and assert that FIP is in
196 203
        # use until notification from ganeti arrives
197 204
        request = {"removeFloatingIp": {"address": ip.ipv4}}
198
        url = "/api/v1.1/servers/%s/action" % vm.id
205
        url = SERVERS_URL + "/%s/action" % vm.id
199 206
        with patch('synnefo.logic.rapi_pool.GanetiRapiClient') as c:
200 207
            c().ModifyInstance.return_value = 10
201 208
            response = self.post(url, vm.userid, json.dumps(request),
......
219 226
        net = ip.network
220 227
        # Can not remove network with floating IPs
221 228
        with mocked_quotaholder():
222
            response = self.delete("/api/v1.1/networks/%s" % net.id,
229
            response = self.delete(NETWORKS_URL + "/%s" % net.id,
223 230
                                   net.userid)
224 231
        self.assertFault(response, 421, "networkInUse")
225 232
        # But we can with only deleted Floating Ips
226 233
        ip.deleted = True
227 234
        ip.save()
228 235
        with mocked_quotaholder():
229
            response = self.delete("/api/v1.1/networks/%s" % net.id,
236
            response = self.delete(NETWORKS_URL + "/%s" % net.id,
230 237
                                   net.userid)
231 238
        self.assertSuccess(response)
232 239

  
233 240

  
234
POOLS_URL = "/api/v1.1/os-floating-ip-pools"
241
POOLS_URL = join_urls(compute_path, "os-floating-ip-pools")
235 242

  
236 243

  
237 244
class FloatingIPPoolsAPITest(BaseAPITest):
......
259 266
        self.vm = vm
260 267

  
261 268
    def test_bad_request(self):
262
        url = "/api/v1.1/servers/%s/action" % self.vm.id
269
        url = SERVERS_URL + "/%s/action" % self.vm.id
263 270
        response = self.post(url, self.vm.userid, json.dumps({}), "json")
264 271
        self.assertBadRequest(response)
265 272
        response = self.post(url, self.vm.userid,
......
270 277
    @patch('synnefo.logic.rapi_pool.GanetiRapiClient')
271 278
    def test_add_floating_ip(self, mock):
272 279
        # Not exists
273
        url = "/api/v1.1/servers/%s/action" % self.vm.id
280
        url = SERVERS_URL + "/%s/action" % self.vm.id
274 281
        request = {"addFloatingIp": {"address": "10.0.0.1"}}
275 282
        response = self.post(url, self.vm.userid, json.dumps(request), "json")
276 283
        self.assertItemNotFound(response)
......
297 304
    @patch('synnefo.logic.rapi_pool.GanetiRapiClient')
298 305
    def test_remove_floating_ip(self, mock):
299 306
        # Not exists
300
        url = "/api/v1.1/servers/%s/action" % self.vm.id
307
        url = SERVERS_URL + "/%s/action" % self.vm.id
301 308
        request = {"removeFloatingIp": {"address": "10.0.0.1"}}
302 309
        response = self.post(url, self.vm.userid, json.dumps(request), "json")
303 310
        self.assertItemNotFound(response)

Also available in: Unified diff