def post_servers_1234_action(self, body, **kw): assert_equal(len(body.keys()), 1) action = body.keys()[0] if action == "reboot": assert_equal(body[action].keys(), ["type"]) assert_in(body[action]["type"], ["HARD", "SOFT"]) elif action == "rebuild": assert_equal(body[action].keys(), ["imageId"]) elif action == "resize": assert_equal(body[action].keys(), ["flavorId"]) elif action == "confirmResize": assert_equal(body[action], None) # This one method returns a different response code return (204, None) elif action == "revertResize": assert_equal(body[action], None) elif action == "migrate": assert_equal(body[action], None) elif action == "addFixedIp": assert_equal(body[action].keys(), ["networkId"]) elif action == "removeFixedIp": assert_equal(body[action].keys(), ["address"]) else: fail("Unexpected server action: %s" % action) return (202, None)
def post_servers_1234_action(self, body, **kw): assert_equal(len(body.keys()), 1) action = body.keys()[0] if action == 'reboot': assert_equal(body[action].keys(), ['type']) assert_in(body[action]['type'], ['HARD', 'SOFT']) elif action == 'rebuild': assert_equal(body[action].keys(), ['imageId']) elif action == 'resize': assert_equal(body[action].keys(), ['flavorId']) elif action == 'createBackup': assert_equal(set(body[action].keys()), set(['name', 'rotation', 'backup_type'])) elif action == 'confirmResize': assert_equal(body[action], None) # This one method returns a different response code return (204, None) elif action == 'revertResize': assert_equal(body[action], None) elif action == 'migrate': assert_equal(body[action], None) elif action == 'addFixedIp': assert_equal(body[action].keys(), ['networkId']) elif action == 'removeFixedIp': assert_equal(body[action].keys(), ['address']) else: fail("Unexpected server action: %s" % action) return (202, None)
def _cs_request(self, url, method, **kwargs): # Check that certain things are called correctly if method in ['GET', 'DELETE']: assert_not_in('body', kwargs) elif method in ['PUT', 'POST']: assert_in('body', kwargs) # Call the method munged_url = url.strip('/').replace('/', '_').replace('.', '_') callback = "%s_%s" % (method.lower(), munged_url) if not hasattr(self, callback): fail('Called unknown API method: %s %s' % (method, url)) # Note the call self.callstack.append((method, url, kwargs.get('body', None))) status, body = getattr(self, callback)(**kwargs) return httplib2.Response({"status": status}), body
def _cs_request(self, url, method, **kwargs): # Check that certain things are called correctly if method in ["GET", "DELETE"]: assert_not_in("body", kwargs) elif method in ["PUT", "POST"]: assert_in("body", kwargs) # Call the method munged_url = url.strip("/").replace("/", "_").replace(".", "_") callback = "%s_%s" % (method.lower(), munged_url) if not hasattr(self, callback): fail("Called unknown API method: %s %s" % (method, url)) # Note the call self.callstack.append((method, url, kwargs.get("body", None))) status, body = getattr(self, callback)(**kwargs) return httplib2.Response({"status": status}), body
def post_servers_1234_action(self, body, **kw): assert_equal(len(body.keys()), 1) action = body.keys()[0] if action == 'reboot': assert_equal(body[action].keys(), ['type']) assert_in(body[action]['type'], ['HARD', 'SOFT']) elif action == 'rebuild': assert_equal(body[action].keys(), ['imageId']) elif action == 'resize': assert_equal(body[action].keys(), ['flavorId']) elif action == 'confirmResize': assert_equal(body[action], None) # This one method returns a different response code return (204, None) elif action == 'revertResize': assert_equal(body[action], None) else: fail("Unexpected server action: %s" % action) return (202, None)
def test_zone_list(): shell('zone-list') assert_in(('GET', '/zones/detail', None), _shell.cs.client.callstack)
def test_ipgroup_list(): shell('ipgroup-list') assert_in(('GET', '/shared_ip_groups/detail', None), _shell.cs.client.callstack) assert_called('GET', '/servers/5678')
def test_ipgroup_list(): shell('ipgroup-list') assert_in(('GET', '/shared_ip_groups/detail', None), _shell.compute.client.callstack) assert_called('GET', '/servers/5678')