From 73872f52287ceb3098499a551ef963ae3f7d38de Mon Sep 17 00:00:00 2001 From: Aymeric Barantal Date: Wed, 21 Sep 2011 12:10:42 +0200 Subject: [PATCH 4/7] pep8 in test_gandi --- test/compute/test_gandi.py | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) diff --git a/test/compute/test_gandi.py b/test/compute/test_gandi.py index 295e3c1..2dd83bc 100644 --- a/test/compute/test_gandi.py +++ b/test/compute/test_gandi.py @@ -28,6 +28,7 @@ from test import MockHttp from test.file_fixtures import ComputeFileFixtures from test.secrets import GANDI_PARAMS + class MockGandiTransport(xmlrpclib.Transport): def request(self, host, handler, request_body, verbose=0): @@ -43,11 +44,14 @@ class MockGandiTransport(xmlrpclib.Transport): response = self.parse_response(resp.body) return response + class GandiTests(unittest.TestCase): node_name = 'test2' + def setUp(self): - Gandi.connectionCls.proxyCls.transportCls = [MockGandiTransport, MockGandiTransport] + Gandi.connectionCls.proxyCls.transportCls = \ + [MockGandiTransport, MockGandiTransport] self.driver = Gandi(*GANDI_PARAMS) def test_list_nodes(self): @@ -55,11 +59,13 @@ class GandiTests(unittest.TestCase): self.assertTrue(len(nodes) > 0) def test_list_locations(self): - loc = filter(lambda x: 'france' in x.country.lower(), self.driver.list_locations())[0] + loc = filter(lambda x: 'france' in x.country.lower(), + self.driver.list_locations())[0] self.assertEqual(loc.country, 'France') def test_list_images(self): - loc = filter(lambda x: 'france' in x.country.lower(), self.driver.list_locations())[0] + loc = filter(lambda x: 'france' in x.country.lower(), + self.driver.list_locations())[0] images = self.driver.list_images(loc) self.assertTrue(len(images) > 2) @@ -84,18 +90,22 @@ class GandiTests(unittest.TestCase): def test_create_node(self): login = 'libcloud' - passwd = ''.join(random.choice(string.letters + string.digits) for i in xrange(10)) + passwd = ''.join(random.choice(string.letters + string.digits) + for i in xrange(10)) # Get france datacenter - loc = filter(lambda x: 'france' in x.country.lower(), self.driver.list_locations())[0] + loc = filter(lambda x: 'france' in x.country.lower(), + self.driver.list_locations())[0] # Get a debian image images = self.driver.list_images(loc) images = [x for x in images if x.name.lower().startswith('debian')] img = filter(lambda x: '5' in x.name, images)[0] # Get a configuration size size = self.driver.list_sizes()[0] - node = self.driver.create_node(name=self.node_name, login=login, password=passwd, image=img, location=loc, size=size) + node = self.driver.create_node(name=self.node_name, login=login, + password=passwd, image=img, location=loc, size=size) self.assertEqual(node.name, self.node_name) + class GandiMockHttp(MockHttp): fixtures = ComputeFileFixtures('gandi') -- 1.7.6.1