Skip to content

Commit f79aac9

Browse files
committed
Code cleanup via flake8.
1 parent 31fe7f6 commit f79aac9

7 files changed

Lines changed: 92 additions & 87 deletions

File tree

api/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def db_type(self, connection=None):
3131
if connection and 'postgres' in connection.vendor:
3232
db_type = 'uuid'
3333
else:
34-
db_type = 'char({0})'.format(self.max_length)
34+
db_type = "char({})".format(self.max_length)
3535
return db_type
3636

3737
def pre_save(self, model_instance, add):

api/models.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Meta:
8787
unique_together = (('owner', 'id'))
8888

8989
def __str__(self):
90-
return '{0} : {1}'.format(self.owner.username, self.id)
90+
return "{0} : {1}".format(self.owner.username, self.id)
9191

9292

9393
@python_2_unicode_compatible
@@ -638,7 +638,7 @@ class Container(UuidAuditedModel):
638638
def __str__(self):
639639
if self.id:
640640
return self.id
641-
return '{0} {1}.{2}'.format(self.formation.id, self.type, self.num)
641+
return "{0} {1}.{2}".format(self.formation.id, self.type, self.num)
642642

643643
class Meta:
644644
get_latest_by = '-created'
@@ -666,7 +666,7 @@ class Meta:
666666
unique_together = (('formation', 'version'),)
667667

668668
def __str__(self):
669-
return '{0}-v{1}'.format(self.formation.id, self.version)
669+
return "{0}-v{1}".format(self.formation.id, self.version)
670670

671671

672672
@python_2_unicode_compatible
@@ -694,7 +694,7 @@ class Meta:
694694
ordering = ['-created']
695695

696696
def __str__(self):
697-
return '{0}-v{1}'.format(self.formation.id, self.version)
697+
return "{0}-v{1}".format(self.formation.id, self.version)
698698

699699
@classmethod
700700
def push(cls, push):
@@ -760,7 +760,7 @@ class Meta:
760760
unique_together = (('formation', 'version'),)
761761

762762
def __str__(self):
763-
return '{0}-v{1}'.format(self.formation.id, self.version)
763+
return "{0}-v{1}".format(self.formation.id, self.version)
764764

765765
def rollback(self):
766766
# create a rollback log entry

api/tests/build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def setUp(self):
2424
self.assertTrue(
2525
self.client.login(username='autotest', password='password'))
2626
url = '/api/providers'
27-
creds = {'secret_key': 'x'*64, 'access_key': 1*20}
27+
creds = {'secret_key': 'x' * 64, 'access_key': 1 * 20}
2828
body = {'id': 'autotest', 'type': 'mock', 'creds': json.dumps(creds)}
2929
response = self.client.post(url, json.dumps(body), content_type='application/json')
3030
self.assertEqual(response.status_code, 201)
@@ -33,7 +33,7 @@ def setUp(self):
3333
'id': 'autotest',
3434
'provider': 'autotest',
3535
'params': json.dumps({'region': 'us-west-2', 'instance_size': 'm1.medium'}),
36-
}
36+
}
3737
response = self.client.post(url, json.dumps(body), content_type='application/json')
3838
self.assertEqual(response.status_code, 201)
3939

@@ -48,7 +48,7 @@ def test_build(self):
4848
self.assertEqual(response.status_code, 201)
4949
formation_id = response.data['id']
5050
# check to see that no initial build was created
51-
url = '/api/formations/{formation_id}/build'.format(**locals())
51+
url = "/api/formations/{formation_id}/build".format(**locals())
5252
response = self.client.get(url)
5353
self.assertEqual(response.status_code, 404)
5454
# post a first build
@@ -75,7 +75,7 @@ def test_build(self):
7575
'procfile': json.dumps({'web': 'node server.js'}),
7676
'url': 'http://deis.local/slugs/1c52739bbf3a44d3bfb9a58f7bbdd5fb.tar.gz',
7777
'checksum': uuid.uuid4().hex,
78-
}
78+
}
7979
response = self.client.post(url, json.dumps(body), content_type='application/json')
8080
self.assertEqual(response.status_code, 201)
8181
build3 = response.data

api/tests/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def setUp(self):
2121
self.assertTrue(
2222
self.client.login(username='autotest', password='password'))
2323
url = '/api/providers'
24-
creds = {'secret_key': 'x'*64, 'access_key': 1*20}
24+
creds = {'secret_key': 'x' * 64, 'access_key': 1 * 20}
2525
body = {'id': 'autotest', 'type': 'mock', 'creds': json.dumps(creds)}
2626
response = self.client.post(url, json.dumps(body), content_type='application/json')
2727
self.assertEqual(response.status_code, 201)
@@ -42,7 +42,7 @@ def test_config(self):
4242
self.assertEqual(response.status_code, 201)
4343
formation_id = response.data['id']
4444
# check to see that an initial/empty config was created
45-
url = '/api/formations/{formation_id}/config'.format(**locals())
45+
url = "/api/formations/{formation_id}/config".format(**locals())
4646
response = self.client.get(url)
4747
self.assertEqual(response.status_code, 200)
4848
self.assertIn('values', response.data)

api/tests/container.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def setUp(self):
2323
self.assertTrue(
2424
self.client.login(username='autotest', password='password'))
2525
url = '/api/providers'
26-
creds = {'access_key': getattr(settings, 'EC2_ACCESS_KEY', 'x'*32),
27-
'secret_key': getattr(settings, 'EC2_SECRET_KEY', 'x'*64)}
26+
creds = {'access_key': getattr(settings, 'EC2_ACCESS_KEY', 'x' * 32),
27+
'secret_key': getattr(settings, 'EC2_SECRET_KEY', 'x' * 64)}
2828
body = {'id': 'autotest', 'type': 'mock', 'creds': json.dumps(creds)}
2929
response = self.client.post(url, json.dumps(body), content_type='application/json')
3030
self.assertEqual(response.status_code, 201)
@@ -40,62 +40,62 @@ def test_container_scale(self):
4040
response = self.client.post(url, json.dumps(body), content_type='application/json')
4141
self.assertEqual(response.status_code, 201)
4242
formation_id = response.data['id']
43-
url = '/api/formations/{formation_id}/layers'.format(**locals())
43+
url = "/api/formations/{formation_id}/layers".format(**locals())
4444
body = {'id': 'runtime', 'flavor': 'autotest', 'run_list': 'recipe[deis::runtime]'}
4545
response = self.client.post(url, json.dumps(body), content_type='application/json')
4646
self.assertEqual(response.status_code, 201)
4747
# scale runtime layer up
48-
url = '/api/formations/{formation_id}/scale/layers'.format(**locals())
48+
url = "/api/formations/{formation_id}/scale/layers".format(**locals())
4949
body = {'runtime': 4}
5050
response = self.client.post(url, json.dumps(body), content_type='application/json')
5151
self.assertEqual(response.status_code, 200)
52-
url = '/api/formations/{formation_id}/nodes'.format(**locals())
52+
url = "/api/formations/{formation_id}/nodes".format(**locals())
5353
response = self.client.get(url)
5454
self.assertEqual(response.status_code, 200)
5555
self.assertEqual(len(response.data['results']), 4)
56-
url = '/api/formations/{formation_id}'.format(**locals())
56+
url = "/api/formations/{formation_id}".format(**locals())
5757
response = self.client.get(url)
5858
self.assertEqual(response.status_code, 200)
5959
# should start with zero
60-
url = '/api/formations/{formation_id}/containers'.format(**locals())
60+
url = "/api/formations/{formation_id}/containers".format(**locals())
6161
response = self.client.get(url)
6262
self.assertEqual(response.status_code, 200)
6363
self.assertEqual(len(response.data['results']), 0)
6464
# scale up
65-
url = '/api/formations/{formation_id}/scale/containers'.format(**locals())
65+
url = "/api/formations/{formation_id}/scale/containers".format(**locals())
6666
body = {'web': 4, 'worker': 2}
6767
response = self.client.post(url, json.dumps(body), content_type='application/json')
6868
self.assertEqual(response.status_code, 200)
69-
url = '/api/formations/{formation_id}/containers'.format(**locals())
69+
url = "/api/formations/{formation_id}/containers".format(**locals())
7070
response = self.client.get(url)
7171
self.assertEqual(response.status_code, 200)
7272
self.assertEqual(len(response.data['results']), 6)
73-
url = '/api/formations/{formation_id}'.format(**locals())
73+
url = "/api/formations/{formation_id}".format(**locals())
7474
response = self.client.get(url)
7575
self.assertEqual(response.status_code, 200)
7676
self.assertEqual(response.data['containers'], json.dumps(body))
7777
# scale down
78-
url = '/api/formations/{formation_id}/scale/containers'.format(**locals())
78+
url = "/api/formations/{formation_id}/scale/containers".format(**locals())
7979
body = {'web': 2, 'worker': 1}
8080
response = self.client.post(url, json.dumps(body), content_type='application/json')
81-
url = '/api/formations/{formation_id}/containers'.format(**locals())
81+
url = "/api/formations/{formation_id}/containers".format(**locals())
8282
response = self.client.get(url)
8383
self.assertEqual(response.status_code, 200)
8484
self.assertEqual(len(response.data['results']), 3)
85-
url = '/api/formations/{formation_id}'.format(**locals())
85+
url = "/api/formations/{formation_id}".format(**locals())
8686
response = self.client.get(url)
8787
self.assertEqual(response.status_code, 200)
8888
self.assertEqual(response.data['containers'], json.dumps(body))
8989
# scale down to 0
90-
url = '/api/formations/{formation_id}/scale/containers'.format(**locals())
90+
url = "/api/formations/{formation_id}/scale/containers".format(**locals())
9191
body = {'web': 0, 'worker': 0}
9292
response = self.client.post(url, json.dumps(body), content_type='application/json')
9393
self.assertEqual(response.status_code, 200)
94-
url = '/api/formations/{formation_id}/containers'.format(**locals())
94+
url = "/api/formations/{formation_id}/containers".format(**locals())
9595
response = self.client.get(url)
9696
self.assertEqual(response.status_code, 200)
9797
self.assertEqual(len(response.data['results']), 0)
98-
url = '/api/formations/{formation_id}'.format(**locals())
98+
url = "/api/formations/{formation_id}".format(**locals())
9999
response = self.client.get(url)
100100
self.assertEqual(response.status_code, 200)
101101
self.assertEqual(response.data['containers'], json.dumps(body))

0 commit comments

Comments
 (0)