diff --git a/novaclient/tests/fakes.py b/novaclient/tests/fakes.py index f3f5274bc..ef6b59b52 100644 --- a/novaclient/tests/fakes.py +++ b/novaclient/tests/fakes.py @@ -30,7 +30,7 @@ def assert_has_keys(dict, required=[], optional=[]): except AssertionError: extra_keys = set(keys).difference(set(required + optional)) raise AssertionError("found unexpected keys: %s" % - list(extra_keys)) + list(extra_keys)) class FakeClient(object): diff --git a/novaclient/tests/fixture_data/client.py b/novaclient/tests/fixture_data/client.py index e52d4a233..094bc969f 100644 --- a/novaclient/tests/fixture_data/client.py +++ b/novaclient/tests/fixture_data/client.py @@ -47,8 +47,8 @@ class V1(fixtures.Fixture): auth_url = '%s/tokens' % self.identity_url headers = {'X-Content-Type': 'application/json'} self.requests.register_uri('POST', auth_url, - json=self.token, - headers=headers) + json=self.token, + headers=headers) self.client = self.new_client() def new_client(self): diff --git a/novaclient/tests/fixture_data/cloudpipe.py b/novaclient/tests/fixture_data/cloudpipe.py index 32b5c210c..9cb4efa89 100644 --- a/novaclient/tests/fixture_data/cloudpipe.py +++ b/novaclient/tests/fixture_data/cloudpipe.py @@ -22,15 +22,15 @@ class Fixture(base.Fixture): get_os_cloudpipe = {'cloudpipes': [{'project_id': 1}]} self.requests.register_uri('GET', self.url(), - json=get_os_cloudpipe, - headers=self.json_headers) + json=get_os_cloudpipe, + headers=self.json_headers) instance_id = '9d5824aa-20e6-4b9f-b967-76a699fc51fd' post_os_cloudpipe = {'instance_id': instance_id} self.requests.register_uri('POST', self.url(), - json=post_os_cloudpipe, - headers=self.json_headers, - status_code=202) + json=post_os_cloudpipe, + headers=self.json_headers, + status_code=202) self.requests.register_uri('PUT', self.url('configure-project'), headers=self.json_headers, diff --git a/novaclient/tests/fixture_data/floatingips.py b/novaclient/tests/fixture_data/floatingips.py index f493e10fb..4829a5a3c 100644 --- a/novaclient/tests/fixture_data/floatingips.py +++ b/novaclient/tests/fixture_data/floatingips.py @@ -47,8 +47,8 @@ class FloatingFixture(base.Fixture): ip['pool'] = body.get('pool') return {'floating_ip': ip} self.requests.register_uri('POST', self.url(), - json=post_os_floating_ips, - headers=self.json_headers) + json=post_os_floating_ips, + headers=self.json_headers) class DNSFixture(base.Fixture): diff --git a/novaclient/tests/fixture_data/networks.py b/novaclient/tests/fixture_data/networks.py index 44d7d528a..023dce421 100644 --- a/novaclient/tests/fixture_data/networks.py +++ b/novaclient/tests/fixture_data/networks.py @@ -44,8 +44,8 @@ class Fixture(base.Fixture): return {'network': body} self.requests.register_uri("POST", self.url(), - json=post_os_networks, - headers=headers) + json=post_os_networks, + headers=headers) get_os_networks_1 = {'network': {"label": "1", "cidr": "10.0.0.0/24"}} diff --git a/novaclient/tests/fixture_data/servers.py b/novaclient/tests/fixture_data/servers.py index b226413c5..d316d4527 100644 --- a/novaclient/tests/fixture_data/servers.py +++ b/novaclient/tests/fixture_data/servers.py @@ -346,7 +346,8 @@ class V1(Base): # tI2/++UsXVg3ow6ItqCJGgdNuGG5JB+bslDHWPxROpesEIHdczk46HCpHQN8f1sk # Hi/fmZZNQQqj1Ijq0caOIw== - get_server_password = {'password': + get_server_password = { + 'password': 'OIuEuQttO8Rk93BcKlwHQsziDAnkAm/V6V8VPToA8ZeUaUBWwS0gwo2K6Y61Z96r' 'qG447iRz0uTEEYq3RAYJk1mh3mMIRVl27t8MtIecR5ggVVbz1S9AwXJQypDKl0ho' 'QFvhCBcMWPohyGewDJOhDbtuN1IoFI9G55ZvFwCm5y7m7B2aVcoLeIsJZE4PLsIw' @@ -543,10 +544,11 @@ class V3(Base): def post_servers(self, request, context): body = jsonutils.loads(request.body) assert set(body.keys()) <= set(['server']) - fakes.assert_has_keys(body['server'], - required=['name', 'image_ref', 'flavor_ref'], - optional=['metadata', 'personality', - 'os-scheduler-hints:scheduler_hints']) + fakes.assert_has_keys( + body['server'], + required=['name', 'image_ref', 'flavor_ref'], + optional=['metadata', 'personality', + 'os-scheduler-hints:scheduler_hints']) if body['server']['name'] == 'some-bad-server': body = self.server_1235 else: diff --git a/novaclient/tests/test_auth_plugins.py b/novaclient/tests/test_auth_plugins.py index ce7e82a8c..33bf481b8 100644 --- a/novaclient/tests/test_auth_plugins.py +++ b/novaclient/tests/test_auth_plugins.py @@ -133,8 +133,8 @@ class DeprecatedAuthPluginTest(utils.TestCase): def mock_iter_entry_points(_type, name): if _type == 'openstack.client.auth_url': return [MockAuthUrlEntrypoint("fakewithauthurl", - "fakewithauthurl", - ["auth_url"])] + "fakewithauthurl", + ["auth_url"])] elif _type == 'openstack.client.authenticate': return [MockAuthenticateEntrypoint("fakewithauthurl", "fakewithauthurl", @@ -221,9 +221,9 @@ class AuthPluginTest(utils.TestCase): @staticmethod def add_opts(parser): parser.add_argument('--auth_system_opt', - default=False, - action='store_true', - help="Fake option") + default=False, + action='store_true', + help="Fake option") return parser class MockEntrypoint(pkg_resources.EntryPoint): @@ -281,8 +281,8 @@ class AuthPluginTest(utils.TestCase): plugin = auth_plugin.load_plugin("fake") cs = client.Client("username", "password", "project_id", - auth_system="fakewithauthurl", - auth_plugin=plugin) + auth_system="fakewithauthurl", + auth_plugin=plugin) self.assertEqual("http://faked/v2.0", cs.client.auth_url) @mock.patch.object(pkg_resources, "iter_entry_points") diff --git a/novaclient/tests/test_client.py b/novaclient/tests/test_client.py index 099b36636..7322b66ac 100644 --- a/novaclient/tests/test_client.py +++ b/novaclient/tests/test_client.py @@ -371,8 +371,9 @@ class ClientTest(utils.TestCase): 'X-Auth-Token': 'totally_bogus'} }) cs.http_log_req('GET', '/foo', {'headers': {}, - 'data': '{"auth": {"passwordCredentials": ' - '{"password": "zhaoqin"}}}'}) + 'data': + '{"auth": {"passwordCredentials": ' + '{"password": "zhaoqin"}}}'}) output = self.logger.output.split('\n') diff --git a/novaclient/tests/v1_1/contrib/fakes.py b/novaclient/tests/v1_1/contrib/fakes.py index 0d4af537c..43c6e6de3 100644 --- a/novaclient/tests/v1_1/contrib/fakes.py +++ b/novaclient/tests/v1_1/contrib/fakes.py @@ -26,19 +26,22 @@ class FakeClient(fakes.FakeClient): class FakeHTTPClient(fakes.FakeHTTPClient): def get_os_tenant_networks(self): - return (200, {}, {'networks': [{"label": "1", "cidr": "10.0.0.0/24", - 'project_id': '4ffc664c198e435e9853f2538fbcd7a7', - 'id': '1'}]}) + return (200, {}, { + 'networks': [{"label": "1", "cidr": "10.0.0.0/24", + 'project_id': '4ffc664c198e435e9853f2538fbcd7a7', + 'id': '1'}]}) def get_os_tenant_networks_1(self, **kw): - return (200, {}, {'network': {"label": "1", "cidr": "10.0.0.0/24", - 'project_id': '4ffc664c198e435e9853f2538fbcd7a7', - 'id': '1'}}) + return (200, {}, { + 'network': {"label": "1", "cidr": "10.0.0.0/24", + 'project_id': '4ffc664c198e435e9853f2538fbcd7a7', + 'id': '1'}}) def post_os_tenant_networks(self, **kw): - return (201, {}, {'network': {"label": "1", "cidr": "10.0.0.0/24", - 'project_id': '4ffc664c198e435e9853f2538fbcd7a7', - 'id': '1'}}) + return (201, {}, { + 'network': {"label": "1", "cidr": "10.0.0.0/24", + 'project_id': '4ffc664c198e435e9853f2538fbcd7a7', + 'id': '1'}}) def delete_os_tenant_networks_1(self, **kw): return (204, {}, None) diff --git a/novaclient/tests/v1_1/contrib/test_assisted_volume_snapshots.py b/novaclient/tests/v1_1/contrib/test_assisted_volume_snapshots.py index c3e47b458..426d6debb 100644 --- a/novaclient/tests/v1_1/contrib/test_assisted_volume_snapshots.py +++ b/novaclient/tests/v1_1/contrib/test_assisted_volume_snapshots.py @@ -37,5 +37,6 @@ class AssistedVolumeSnapshotsTestCase(utils.TestCase): def test_delete_snap(self): cs.assisted_volume_snapshots.delete('x', {}) - cs.assert_called('DELETE', - '/os-assisted-volume-snapshots/x?delete_info={}') + cs.assert_called( + 'DELETE', + '/os-assisted-volume-snapshots/x?delete_info={}') diff --git a/novaclient/tests/v1_1/contrib/test_instance_actions.py b/novaclient/tests/v1_1/contrib/test_instance_actions.py index baaa1d040..364781975 100644 --- a/novaclient/tests/v1_1/contrib/test_instance_actions.py +++ b/novaclient/tests/v1_1/contrib/test_instance_actions.py @@ -30,12 +30,14 @@ class InstanceActionExtensionTests(utils.TestCase): def test_list_instance_actions(self): server_uuid = '1234' cs.instance_action.list(server_uuid) - cs.assert_called('GET', '/servers/%s/os-instance-actions' % - server_uuid) + cs.assert_called( + 'GET', '/servers/%s/os-instance-actions' % + server_uuid) def test_get_instance_action(self): server_uuid = '1234' request_id = 'req-abcde12345' cs.instance_action.get(server_uuid, request_id) - cs.assert_called('GET', '/servers/%s/os-instance-actions/%s' % - (server_uuid, request_id)) + cs.assert_called( + 'GET', '/servers/%s/os-instance-actions/%s' + % (server_uuid, request_id)) diff --git a/novaclient/tests/v1_1/fakes.py b/novaclient/tests/v1_1/fakes.py index dfc7077ac..53f9e7451 100644 --- a/novaclient/tests/v1_1/fakes.py +++ b/novaclient/tests/v1_1/fakes.py @@ -95,22 +95,22 @@ class FakeHTTPClient(base_client.HTTPClient): def get_os_agents(self, **kw): hypervisor = kw.get('hypervisor', 'kvm') - return (200, {}, {'agents': - [{'hypervisor': hypervisor, - 'os': 'win', - 'architecture': 'x86', - 'version': '7.0', - 'url': 'xxx://xxxx/xxx/xxx', - 'md5hash': 'add6bb58e139be103324d04d82d8f545', - 'id': 1}, - {'hypervisor': hypervisor, - 'os': 'linux', - 'architecture': 'x86', - 'version': '16.0', - 'url': 'xxx://xxxx/xxx/xxx1', - 'md5hash': 'add6bb58e139be103324d04d82d8f546', - 'id': 2}, - ]}) + return (200, {}, { + 'agents': + [{'hypervisor': hypervisor, + 'os': 'win', + 'architecture': 'x86', + 'version': '7.0', + 'url': 'xxx://xxxx/xxx/xxx', + 'md5hash': 'add6bb58e139be103324d04d82d8f545', + 'id': 1}, + {'hypervisor': hypervisor, + 'os': 'linux', + 'architecture': 'x86', + 'version': '16.0', + 'url': 'xxx://xxxx/xxx/xxx1', + 'md5hash': 'add6bb58e139be103324d04d82d8f546', + 'id': 2}]}) def post_os_agents(self, body): return (200, {}, {'agent': { @@ -366,9 +366,10 @@ class FakeHTTPClient(base_client.HTTPClient): def post_servers(self, body, **kw): assert set(body.keys()) <= set(['server', 'os:scheduler_hints']) - fakes.assert_has_keys(body['server'], - required=['name', 'imageRef', 'flavorRef'], - optional=['metadata', 'personality']) + fakes.assert_has_keys( + body['server'], + required=['name', 'imageRef', 'flavorRef'], + optional=['metadata', 'personality']) if 'personality' in body['server']: for pfile in body['server']['personality']: fakes.assert_has_keys(pfile, required=['path', 'contents']) @@ -379,9 +380,10 @@ class FakeHTTPClient(base_client.HTTPClient): def post_os_volumes_boot(self, body, **kw): assert set(body.keys()) <= set(['server', 'os:scheduler_hints']) - fakes.assert_has_keys(body['server'], - required=['name', 'flavorRef'], - optional=['imageRef']) + fakes.assert_has_keys( + body['server'], + required=['name', 'flavorRef'], + optional=['imageRef']) # Require one, and only one, of the keys for bdm if 'block_device_mapping' not in body['server']: @@ -487,16 +489,20 @@ class FakeHTTPClient(base_client.HTTPClient): # def get_servers_1234_ips(self, **kw): - return (200, {}, {'addresses': - self.get_servers_1234()[1]['server']['addresses']}) + return (200, {}, { + 'addresses': + self.get_servers_1234()[1]['server']['addresses']}) def get_servers_1234_ips_public(self, **kw): - return (200, {}, {'public': - self.get_servers_1234_ips()[1]['addresses']['public']}) + return (200, {}, { + 'public': + self.get_servers_1234_ips()[1]['addresses']['public']}) def get_servers_1234_ips_private(self, **kw): - return (200, {}, {'private': - self.get_servers_1234_ips()[1]['addresses']['private']}) + return ( + 200, {}, + {'private': + self.get_servers_1234_ips()[1]['addresses']['private']}) def delete_servers_1234_ips_public_1_2_3_4(self, **kw): return (202, {}, None) @@ -519,7 +525,8 @@ class FakeHTTPClient(base_client.HTTPClient): # tI2/++UsXVg3ow6ItqCJGgdNuGG5JB+bslDHWPxROpesEIHdczk46HCpHQN8f1sk # Hi/fmZZNQQqj1Ijq0caOIw== def get_servers_1234_os_server_password(self, **kw): - return (200, {}, {'password': + return (200, {}, { + 'password': 'OIuEuQttO8Rk93BcKlwHQsziDAnkAm/V6V8VPToA8ZeUaUBWwS0gwo2K6Y61Z96r' 'qG447iRz0uTEEYq3RAYJk1mh3mMIRVl27t8MtIecR5ggVVbz1S9AwXJQypDKl0ho' 'QFvhCBcMWPohyGewDJOhDbtuN1IoFI9G55ZvFwCm5y7m7B2aVcoLeIsJZE4PLsIw' @@ -797,21 +804,25 @@ class FakeHTTPClient(base_client.HTTPClient): ) def get_flavors_1_os_extra_specs(self, **kw): - return (200, + return ( + 200, {}, {'extra_specs': {"k1": "v1"}}) def get_flavors_2_os_extra_specs(self, **kw): - return (200, + return ( + 200, {}, {'extra_specs': {"k2": "v2"}}) def get_flavors_aa1_os_extra_specs(self, **kw): - return (200, {}, + return ( + 200, {}, {'extra_specs': {"k3": "v3"}}) def get_flavors_4_os_extra_specs(self, **kw): - return (200, + return ( + 200, {}, {'extra_specs': {"k4": "v4"}}) @@ -819,14 +830,16 @@ class FakeHTTPClient(base_client.HTTPClient): assert list(body) == ['extra_specs'] fakes.assert_has_keys(body['extra_specs'], required=['k1']) - return (200, + return ( + 200, {}, {'extra_specs': {"k1": "v1"}}) def post_flavors_4_os_extra_specs(self, body, **kw): assert list(body) == ['extra_specs'] - return (200, + return ( + 200, {}, body) @@ -841,10 +854,10 @@ class FakeHTTPClient(base_client.HTTPClient): return (404, {}, None) def get_flavors_2_os_flavor_access(self, **kw): - return (200, {}, {'flavor_access': [ - {'flavor_id': '2', 'tenant_id': 'proj1'}, - {'flavor_id': '2', 'tenant_id': 'proj2'} - ]}) + return ( + 200, {}, + {'flavor_access': [{'flavor_id': '2', 'tenant_id': 'proj1'}, + {'flavor_id': '2', 'tenant_id': 'proj2'}]}) def post_flavors_2_action(self, body, **kw): return (202, {}, self.get_flavors_2_os_flavor_access()[2]) @@ -871,19 +884,21 @@ class FakeHTTPClient(base_client.HTTPClient): ) def get_os_floating_ips_1(self, **kw): - return (200, {}, {'floating_ip': - {'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1'} - }) + return ( + 200, {}, {'floating_ip': {'id': 1, 'fixed_ip': '10.0.0.1', + 'ip': '11.0.0.1'}}) def post_os_floating_ips(self, body): if body.get('pool'): - return (200, {}, {'floating_ip': - {'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1', - 'pool': 'nova'}}) + return ( + 200, {}, {'floating_ip': {'id': 1, 'fixed_ip': '10.0.0.1', + 'ip': '11.0.0.1', + 'pool': 'nova'}}) else: - return (200, {}, {'floating_ip': - {'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1', - 'pool': None}}) + return ( + 200, {}, {'floating_ip': {'id': 1, 'fixed_ip': '10.0.0.1', + 'ip': '11.0.0.1', + 'pool': None}}) def delete_os_floating_ips_1(self, **kw): return (204, {}, None) @@ -1016,7 +1031,8 @@ class FakeHTTPClient(base_client.HTTPClient): assert list(body) == ['metadata'] fakes.assert_has_keys(body['metadata'], required=['test_key']) - return (200, + return ( + 200, {}, {'metadata': self.get_images_1()[2]['image']['metadata']}) @@ -1247,7 +1263,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'security_group_rules': 1}}) def put_os_quota_class_sets_97f4c221bff44578b0300df4ef119353(self, - body, **kw): + body, **kw): assert list(body) == ['quota_class_set'] return (200, {}, { 'quota_class_set': { @@ -1391,11 +1407,11 @@ class FakeHTTPClient(base_client.HTTPClient): def post_os_security_group_default_rules(self, body, **kw): assert list(body) == ['security_group_default_rule'] fakes.assert_has_keys(body['security_group_default_rule'], - optional=['ip_protocol', 'from_port', - 'to_port', 'cidr']) + optional=['ip_protocol', 'from_port', + 'to_port', 'cidr']) rules = self.get_os_security_group_default_rules() r = {'security_group_default_rule': - rules[2]['security_group_default_rules'][0]} + rules[2]['security_group_default_rules'][0]} return (202, {}, r) # @@ -1569,24 +1585,21 @@ class FakeHTTPClient(base_client.HTTPClient): def get_os_services(self, **kw): host = kw.get('host', 'host1') binary = kw.get('binary', 'nova-compute') - return (200, {}, {'services': - [{'binary': binary, - 'host': host, - 'zone': 'nova', - 'status': 'enabled', - 'state': 'up', - 'updated_at': datetime.datetime( - 2012, 10, 29, 13, 42, 2 - )}, - {'binary': binary, - 'host': host, - 'zone': 'nova', - 'status': 'disabled', - 'state': 'down', - 'updated_at': datetime.datetime( - 2012, 9, 18, 8, 3, 38 - )}, - ]}) + return (200, {}, {'services': [{'binary': binary, + 'host': host, + 'zone': 'nova', + 'status': 'enabled', + 'state': 'up', + 'updated_at': datetime.datetime( + 2012, 10, 29, 13, 42, 2)}, + {'binary': binary, + 'host': host, + 'zone': 'nova', + 'status': 'disabled', + 'state': 'down', + 'updated_at': datetime.datetime( + 2012, 9, 18, 8, 3, 38)}, + ]}) def put_os_services_enable(self, body, **kw): return (200, {}, {'service': {'host': body['host'], @@ -1599,10 +1612,11 @@ class FakeHTTPClient(base_client.HTTPClient): 'status': 'disabled'}}) def put_os_services_disable_log_reason(self, body, **kw): - return (200, {}, {'service': {'host': body['host'], - 'binary': body['binary'], - 'status': 'disabled', - 'disabled_reason': body['disabled_reason']}}) + return (200, {}, {'service': { + 'host': body['host'], + 'binary': body['binary'], + 'status': 'disabled', + 'disabled_reason': body['disabled_reason']}}) def delete_os_services_1(self, **kw): return (204, {}, None) @@ -1611,11 +1625,10 @@ class FakeHTTPClient(base_client.HTTPClient): # Fixed IPs # def get_os_fixed_ips_192_168_1_1(self, *kw): - return (200, {}, {"fixed_ip": - {'cidr': '192.168.1.0/24', - 'address': '192.168.1.1', - 'hostname': 'foo', - 'host': 'bar'}}) + return (200, {}, {"fixed_ip": {'cidr': '192.168.1.0/24', + 'address': '192.168.1.1', + 'hostname': 'foo', + 'host': 'bar'}}) def post_os_fixed_ips_192_168_1_1_action(self, body, **kw): return (202, {}, None) @@ -1636,29 +1649,28 @@ class FakeHTTPClient(base_client.HTTPClient): def get_os_hosts(self, **kw): zone = kw.get('zone', 'nova1') - return (200, {}, {'hosts': - [{'host': 'host1', - 'service': 'nova-compute', - 'zone': zone}, - {'host': 'host1', - 'service': 'nova-cert', - 'zone': zone}]}) + return (200, {}, {'hosts': [{'host': 'host1', + 'service': 'nova-compute', + 'zone': zone}, + {'host': 'host1', + 'service': 'nova-cert', + 'zone': zone}]}) def get_os_hosts_sample_host(self, *kw): return (200, {}, {'host': [{'resource': {'host': 'sample_host'}}], }) def put_os_hosts_sample_host_1(self, body, **kw): return (200, {}, {'host': 'sample-host_1', - 'status': 'enabled'}) + 'status': 'enabled'}) def put_os_hosts_sample_host_2(self, body, **kw): return (200, {}, {'host': 'sample-host_2', - 'maintenance_mode': 'on_maintenance'}) + 'maintenance_mode': 'on_maintenance'}) def put_os_hosts_sample_host_3(self, body, **kw): return (200, {}, {'host': 'sample-host_3', - 'status': 'enabled', - 'maintenance_mode': 'on_maintenance'}) + 'status': 'enabled', + 'maintenance_mode': 'on_maintenance'}) def get_os_hosts_sample_host_reboot(self, **kw): return (200, {}, {'host': 'sample_host', @@ -1793,8 +1805,9 @@ class FakeHTTPClient(base_client.HTTPClient): def get_os_networks(self, **kw): return (200, {}, {'networks': [{"label": "1", "cidr": "10.0.0.0/24", - 'project_id': '4ffc664c198e435e9853f2538fbcd7a7', - 'id': '1', 'vlan': '1234'}]}) + 'project_id': + '4ffc664c198e435e9853f2538fbcd7a7', + 'id': '1', 'vlan': '1234'}]}) def delete_os_networks_1(self, **kw): return (202, {}, None) diff --git a/novaclient/tests/v1_1/test_agents.py b/novaclient/tests/v1_1/test_agents.py index 424a52b79..dbe7af49a 100644 --- a/novaclient/tests/v1_1/test_agents.py +++ b/novaclient/tests/v1_1/test_agents.py @@ -27,8 +27,8 @@ class AgentsTest(utils.FixturedTestCase): ('session', {'client_fixture_class': client.SessionV1})] def stub_hypervisors(self, hypervisor='kvm'): - get_os_agents = {'agents': - [ + get_os_agents = { + 'agents': [ { 'hypervisor': hypervisor, 'os': 'win', @@ -73,16 +73,15 @@ class AgentsTest(utils.FixturedTestCase): def test_agents_create(self): ag = self.cs.agents.create('win', 'x86', '7.0', - '/xxx/xxx/xxx', - 'add6bb58e139be103324d04d82d8f546', - 'xen') - body = {'agent': { - 'url': '/xxx/xxx/xxx', - 'hypervisor': 'xen', - 'md5hash': 'add6bb58e139be103324d04d82d8f546', - 'version': '7.0', - 'architecture': 'x86', - 'os': 'win'}} + '/xxx/xxx/xxx', + 'add6bb58e139be103324d04d82d8f546', + 'xen') + body = {'agent': {'url': '/xxx/xxx/xxx', + 'hypervisor': 'xen', + 'md5hash': 'add6bb58e139be103324d04d82d8f546', + 'version': '7.0', + 'architecture': 'x86', + 'os': 'win'}} self.assert_called('POST', '/os-agents', body) self.assertEqual(1, ag._info.copy()['id']) @@ -98,8 +97,8 @@ class AgentsTest(utils.FixturedTestCase): def test_agents_modify(self): ag = self.cs.agents.update('1', '8.0', - '/yyy/yyyy/yyyy', - 'add6bb58e139be103324d04d82d8f546') + '/yyy/yyyy/yyyy', + 'add6bb58e139be103324d04d82d8f546') body = self._build_example_update_body() self.assert_called('PUT', '/os-agents/1', body) self.assertEqual(1, ag.id) diff --git a/novaclient/tests/v1_1/test_availability_zone.py b/novaclient/tests/v1_1/test_availability_zone.py index 6851d9aea..be0623adf 100644 --- a/novaclient/tests/v1_1/test_availability_zone.py +++ b/novaclient/tests/v1_1/test_availability_zone.py @@ -75,14 +75,14 @@ class AvailabilityZoneTest(utils.FixturedTestCase): l0 = [six.u('zone-1'), six.u('available')] l1 = [six.u('|- fake_host-1'), six.u('')] l2 = [six.u('| |- nova-compute'), - six.u('enabled :-) 2012-12-26 14:45:25')] + six.u('enabled :-) 2012-12-26 14:45:25')] l3 = [six.u('internal'), six.u('available')] l4 = [six.u('|- fake_host-1'), six.u('')] l5 = [six.u('| |- nova-sched'), - six.u('enabled :-) 2012-12-26 14:45:25')] + six.u('enabled :-) 2012-12-26 14:45:25')] l6 = [six.u('|- fake_host-2'), six.u('')] l7 = [six.u('| |- nova-network'), - six.u('enabled XXX 2012-12-26 14:45:24')] + six.u('enabled XXX 2012-12-26 14:45:24')] l8 = [six.u('zone-2'), six.u('not available')] z0 = self.shell._treeizeAvailabilityZone(zones[0]) diff --git a/novaclient/tests/v1_1/test_flavors.py b/novaclient/tests/v1_1/test_flavors.py index 8f5aea007..a69db858f 100644 --- a/novaclient/tests/v1_1/test_flavors.py +++ b/novaclient/tests/v1_1/test_flavors.py @@ -130,8 +130,8 @@ class FlavorsTest(utils.TestCase): def test_create_with_id_as_string(self): flavor_id = 'foobar' f = self.cs.flavors.create("flavorcreate", 512, - 1, 10, flavor_id, ephemeral=10, - is_public=False) + 1, 10, flavor_id, ephemeral=10, + is_public=False) body = self._create_body("flavorcreate", 512, 1, 10, 10, flavor_id, 0, 1.0, False) @@ -189,7 +189,7 @@ class FlavorsTest(utils.TestCase): f = self.cs.flavors.get(1) f.set_keys({'k1': 'v1'}) self.cs.assert_called('POST', '/flavors/1/os-extra_specs', - {"extra_specs": {'k1': 'v1'}}) + {"extra_specs": {'k1': 'v1'}}) def test_set_with_valid_keys(self): valid_keys = ['key4', 'month.price', 'I-Am:AK-ey.44-', diff --git a/novaclient/tests/v1_1/test_images.py b/novaclient/tests/v1_1/test_images.py index e237bcd5c..e5fcfca9b 100644 --- a/novaclient/tests/v1_1/test_images.py +++ b/novaclient/tests/v1_1/test_images.py @@ -54,7 +54,7 @@ class ImagesTest(utils.FixturedTestCase): def test_set_meta(self): self.cs.images.set_meta(1, {'test_key': 'test_value'}) self.assert_called('POST', '/images/1/metadata', - {"metadata": {'test_key': 'test_value'}}) + {"metadata": {'test_key': 'test_value'}}) def test_find(self): i = self.cs.images.find(name="CentOS 5.2") diff --git a/novaclient/tests/v1_1/test_security_group_rules.py b/novaclient/tests/v1_1/test_security_group_rules.py index bf69a86ed..7de882f96 100644 --- a/novaclient/tests/v1_1/test_security_group_rules.py +++ b/novaclient/tests/v1_1/test_security_group_rules.py @@ -65,14 +65,17 @@ class SecurityGroupRulesTest(utils.FixturedTestCase): def test_invalid_parameters_create(self): self.assertRaises(exceptions.CommandError, - self.cs.security_group_rules.create, - 1, "invalid_ip_protocol", 1, 65535, "10.0.0.0/16", 101) + self.cs.security_group_rules.create, + 1, "invalid_ip_protocol", 1, 65535, + "10.0.0.0/16", 101) self.assertRaises(exceptions.CommandError, - self.cs.security_group_rules.create, - 1, "tcp", "invalid_from_port", 65535, "10.0.0.0/16", 101) + self.cs.security_group_rules.create, + 1, "tcp", "invalid_from_port", 65535, + "10.0.0.0/16", 101) self.assertRaises(exceptions.CommandError, - self.cs.security_group_rules.create, - 1, "tcp", 1, "invalid_to_port", "10.0.0.0/16", 101) + self.cs.security_group_rules.create, + 1, "tcp", 1, "invalid_to_port", + "10.0.0.0/16", 101) def test_security_group_rule_str(self): sg = self.cs.security_group_rules.create(1, "tcp", 1, 65535, diff --git a/novaclient/tests/v1_1/test_servers.py b/novaclient/tests/v1_1/test_servers.py index 9d2b495b6..3797e5754 100644 --- a/novaclient/tests/v1_1/test_servers.py +++ b/novaclient/tests/v1_1/test_servers.py @@ -377,7 +377,7 @@ class ServersTest(utils.FixturedTestCase): s.add_floating_ip('11.0.0.1', fixed_address='12.0.0.1') self.assert_called('POST', '/servers/1234/action') self.cs.servers.add_floating_ip(s, '11.0.0.1', - fixed_address='12.0.0.1') + fixed_address='12.0.0.1') self.assert_called('POST', '/servers/1234/action') f = self.cs.floating_ips.list()[0] self.cs.servers.add_floating_ip(s, f) @@ -598,7 +598,7 @@ class ServersTest(utils.FixturedTestCase): disk_over_commit=False) self.assert_called('POST', '/servers/1234/action') self.cs.servers.live_migrate(s, host='hostname', block_migration=False, - disk_over_commit=False) + disk_over_commit=False) self.assert_called('POST', '/servers/1234/action') def test_reset_state(self): diff --git a/novaclient/tests/v1_1/test_shell.py b/novaclient/tests/v1_1/test_shell.py index 55b6137fd..622e082fc 100644 --- a/novaclient/tests/v1_1/test_shell.py +++ b/novaclient/tests/v1_1/test_shell.py @@ -841,17 +841,20 @@ class ShellTest(utils.TestCase): def test_list_by_tenant(self): self.run_command('list --tenant fake_tenant') - self.assert_called('GET', + self.assert_called( + 'GET', '/servers/detail?all_tenants=1&tenant_id=fake_tenant') def test_list_by_user(self): self.run_command('list --user fake_user') - self.assert_called('GET', + self.assert_called( + 'GET', '/servers/detail?all_tenants=1&user_id=fake_user') def test_list_fields(self): - output = self.run_command('list --fields ' - 'host,security_groups,OS-EXT-MOD:some_thing') + output = self.run_command( + 'list --fields ' + 'host,security_groups,OS-EXT-MOD:some_thing') self.assert_called('GET', '/servers/detail') self.assertIn('computenode1', output) self.assertIn('securitygroup1', output) @@ -1661,26 +1664,32 @@ class ShellTest(utils.TestCase): self.assert_called('GET', '/os-hypervisors/statistics') def test_quota_show(self): - self.run_command('quota-show --tenant ' - '97f4c221bff44578b0300df4ef119353') - self.assert_called('GET', - '/os-quota-sets/97f4c221bff44578b0300df4ef119353') + self.run_command( + 'quota-show --tenant ' + '97f4c221bff44578b0300df4ef119353') + self.assert_called( + 'GET', + '/os-quota-sets/97f4c221bff44578b0300df4ef119353') def test_user_quota_show(self): - self.run_command('quota-show --tenant ' - '97f4c221bff44578b0300df4ef119353 --user u1') - self.assert_called('GET', - '/os-quota-sets/97f4c221bff44578b0300df4ef119353?user_id=u1') + self.run_command( + 'quota-show --tenant ' + '97f4c221bff44578b0300df4ef119353 --user u1') + self.assert_called( + 'GET', + '/os-quota-sets/97f4c221bff44578b0300df4ef119353?user_id=u1') def test_quota_show_no_tenant(self): self.run_command('quota-show') self.assert_called('GET', '/os-quota-sets/tenant_id') def test_quota_defaults(self): - self.run_command('quota-defaults --tenant ' - '97f4c221bff44578b0300df4ef119353') - self.assert_called('GET', - '/os-quota-sets/97f4c221bff44578b0300df4ef119353/defaults') + self.run_command( + 'quota-defaults --tenant ' + '97f4c221bff44578b0300df4ef119353') + self.assert_called( + 'GET', + '/os-quota-sets/97f4c221bff44578b0300df4ef119353/defaults') def test_quota_defaults_no_tenant(self): self.run_command('quota-defaults') @@ -1736,8 +1745,9 @@ class ShellTest(utils.TestCase): self.run_command('quota-delete --tenant ' '97f4c221bff44578b0300df4ef119353 ' '--user u1') - self.assert_called('DELETE', - '/os-quota-sets/97f4c221bff44578b0300df4ef119353?user_id=u1') + self.assert_called( + 'DELETE', + '/os-quota-sets/97f4c221bff44578b0300df4ef119353?user_id=u1') def test_quota_class_show(self): self.run_command('quota-class-show test') @@ -1767,8 +1777,9 @@ class ShellTest(utils.TestCase): self.assert_called('GET', '/os-networks') def test_network_list_fields(self): - output = self.run_command('network-list --fields ' - 'vlan,project_id') + output = self.run_command( + 'network-list --fields ' + 'vlan,project_id') self.assert_called('GET', '/os-networks') self.assertIn('1234', output) self.assertIn('4ffc664c198e435e9853f2538fbcd7a7', output) @@ -2133,8 +2144,9 @@ class ShellTest(utils.TestCase): def test_instance_action_get(self): self.run_command('instance-action sample-server req-abcde12345') - self.assert_called('GET', - '/servers/1234/os-instance-actions/req-abcde12345') + self.assert_called( + 'GET', + '/servers/1234/os-instance-actions/req-abcde12345') def test_cell_show(self): self.run_command('cell-show child_cell') @@ -2166,11 +2178,11 @@ class ShellTest(utils.TestCase): addresses = { "skynet": [ {'version': 4, 'addr': "1.1.1.1", - "OS-EXT-IPS:type": 'fixed'}, + "OS-EXT-IPS:type": 'fixed'}, {'version': 4, 'addr': "2.2.2.2", - "OS-EXT-IPS:type": 'floating'}, + "OS-EXT-IPS:type": 'floating'}, {'version': 6, 'addr': "2607:f0d0:1002::4", - "OS-EXT-IPS:type": 'fixed'}, + "OS-EXT-IPS:type": 'fixed'}, {'version': 6, 'addr': "7612:a1b2:2004::6"} ] } @@ -2214,10 +2226,10 @@ class ShellTest(utils.TestCase): addresses = { "skynet": [ {'version': 4, 'addr': "1.1.1.1", - "OS-EXT-IPS:type": 'fixed'}, + "OS-EXT-IPS:type": 'fixed'}, {'version': 4, 'addr': "2.2.2.2"}, {'version': 6, 'addr': "2607:f0d0:1002::4", - "OS-EXT-IPS:type": 'fixed'} + "OS-EXT-IPS:type": 'fixed'} ], "other": [ {'version': 4, 'addr': "2.3.4.5"}, @@ -2241,11 +2253,12 @@ class ShellTest(utils.TestCase): {'name': 'test'}}) @mock.patch.object(builtins, 'open', - mock.mock_open(read_data='FAKE_PUBLIC_KEY')) + mock.mock_open(read_data='FAKE_PUBLIC_KEY')) def test_keypair_import(self): self.run_command('keypair-add --pub-key test.pub test') - self.assert_called('POST', '/os-keypairs', { - 'keypair': {'public_key': 'FAKE_PUBLIC_KEY', 'name': 'test'}}) + self.assert_called( + 'POST', '/os-keypairs', { + 'keypair': {'public_key': 'FAKE_PUBLIC_KEY', 'name': 'test'}}) def test_keypair_list(self): self.run_command('keypair-list') diff --git a/novaclient/tests/v1_1/test_usage.py b/novaclient/tests/v1_1/test_usage.py index 99d40c088..fe0f1e944 100644 --- a/novaclient/tests/v1_1/test_usage.py +++ b/novaclient/tests/v1_1/test_usage.py @@ -34,11 +34,12 @@ class UsageTest(utils.TestCase): now = datetime.datetime.now() usages = self.cs.usage.list(now, now, detailed) - self.cs.assert_called('GET', - "/os-simple-tenant-usage?" + - ("start=%s&" % now.isoformat()) + - ("end=%s&" % now.isoformat()) + - ("detailed=%s" % int(bool(detailed)))) + self.cs.assert_called( + 'GET', + "/os-simple-tenant-usage?" + + ("start=%s&" % now.isoformat()) + + ("end=%s&" % now.isoformat()) + + ("detailed=%s" % int(bool(detailed)))) [self.assertIsInstance(u, usage.Usage) for u in usages] def test_usage_list_detailed(self): @@ -48,8 +49,9 @@ class UsageTest(utils.TestCase): now = datetime.datetime.now() u = self.cs.usage.get("tenantfoo", now, now) - self.cs.assert_called('GET', - "/os-simple-tenant-usage/tenantfoo?" + - ("start=%s&" % now.isoformat()) + - ("end=%s" % now.isoformat())) + self.cs.assert_called( + 'GET', + "/os-simple-tenant-usage/tenantfoo?" + + ("start=%s&" % now.isoformat()) + + ("end=%s" % now.isoformat())) self.assertIsInstance(u, usage.Usage) diff --git a/novaclient/tests/v3/fakes.py b/novaclient/tests/v3/fakes.py index 4fbd1d317..f0c57f76b 100644 --- a/novaclient/tests/v3/fakes.py +++ b/novaclient/tests/v3/fakes.py @@ -38,16 +38,16 @@ class FakeHTTPClient(fakes_v1_1.FakeHTTPClient): # def put_os_hosts_sample_host_1(self, body, **kw): return (200, {}, {'host': {'host': 'sample-host_1', - 'status': 'enabled'}}) + 'status': 'enabled'}}) def put_os_hosts_sample_host_2(self, body, **kw): return (200, {}, {'host': {'host': 'sample-host_2', - 'maintenance_mode': 'on_maintenance'}}) + 'maintenance_mode': 'on_maintenance'}}) def put_os_hosts_sample_host_3(self, body, **kw): return (200, {}, {'host': {'host': 'sample-host_3', - 'status': 'enabled', - 'maintenance_mode': 'on_maintenance'}}) + 'status': 'enabled', + 'maintenance_mode': 'on_maintenance'}}) def get_os_hosts_sample_host_reboot(self, **kw): return (200, {}, {'host': {'host': 'sample_host', @@ -173,9 +173,9 @@ class FakeHTTPClient(fakes_v1_1.FakeHTTPClient): def post_servers(self, body, **kw): assert set(body.keys()) <= set(['server']) fakes.assert_has_keys(body['server'], - required=['name', 'image_ref', 'flavor_ref'], - optional=['metadata', 'personality', - 'os-scheduler-hints:scheduler_hints']) + required=['name', 'image_ref', 'flavor_ref'], + optional=['metadata', 'personality', + 'os-scheduler-hints:scheduler_hints']) if body['server']['name'] == 'some-bad-server': return (202, {}, self.get_servers_1235()[2]) else: diff --git a/novaclient/tests/v3/test_flavors.py b/novaclient/tests/v3/test_flavors.py index 4dadc0ab5..03dee061d 100644 --- a/novaclient/tests/v3/test_flavors.py +++ b/novaclient/tests/v3/test_flavors.py @@ -47,7 +47,7 @@ class FlavorsTest(test_flavors.FlavorsTest): f = self.cs.flavors.get(1) f.set_keys({'k1': 'v1'}) self.cs.assert_called('POST', '/flavors/1/flavor-extra-specs', - {"extra_specs": {'k1': 'v1'}}) + {"extra_specs": {'k1': 'v1'}}) def test_set_with_valid_keys(self): valid_keys = ['key4', 'month.price', 'I-Am:AK-ey.44-',