Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Code cleanup via flake8.
Browse files Browse the repository at this point in the history
  • Loading branch information
mboersma committed Jul 29, 2013
1 parent 31fe7f6 commit f79aac9
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 87 deletions.
2 changes: 1 addition & 1 deletion api/fields.py
Expand Up @@ -31,7 +31,7 @@ def db_type(self, connection=None):
if connection and 'postgres' in connection.vendor:
db_type = 'uuid'
else:
db_type = 'char({0})'.format(self.max_length)
db_type = "char({})".format(self.max_length)
return db_type

def pre_save(self, model_instance, add):
Expand Down
10 changes: 5 additions & 5 deletions api/models.py
Expand Up @@ -87,7 +87,7 @@ class Meta:
unique_together = (('owner', 'id'))

def __str__(self):
return '{0} : {1}'.format(self.owner.username, self.id)
return "{0} : {1}".format(self.owner.username, self.id)


@python_2_unicode_compatible
Expand Down Expand Up @@ -638,7 +638,7 @@ class Container(UuidAuditedModel):
def __str__(self):
if self.id:
return self.id
return '{0} {1}.{2}'.format(self.formation.id, self.type, self.num)
return "{0} {1}.{2}".format(self.formation.id, self.type, self.num)

class Meta:
get_latest_by = '-created'
Expand Down Expand Up @@ -666,7 +666,7 @@ class Meta:
unique_together = (('formation', 'version'),)

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


@python_2_unicode_compatible
Expand Down Expand Up @@ -694,7 +694,7 @@ class Meta:
ordering = ['-created']

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

@classmethod
def push(cls, push):
Expand Down Expand Up @@ -760,7 +760,7 @@ class Meta:
unique_together = (('formation', 'version'),)

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

def rollback(self):
# create a rollback log entry
Expand Down
8 changes: 4 additions & 4 deletions api/tests/build.py
Expand Up @@ -24,7 +24,7 @@ def setUp(self):
self.assertTrue(
self.client.login(username='autotest', password='password'))
url = '/api/providers'
creds = {'secret_key': 'x'*64, 'access_key': 1*20}
creds = {'secret_key': 'x' * 64, 'access_key': 1 * 20}
body = {'id': 'autotest', 'type': 'mock', 'creds': json.dumps(creds)}
response = self.client.post(url, json.dumps(body), content_type='application/json')
self.assertEqual(response.status_code, 201)
Expand All @@ -33,7 +33,7 @@ def setUp(self):
'id': 'autotest',
'provider': 'autotest',
'params': json.dumps({'region': 'us-west-2', 'instance_size': 'm1.medium'}),
}
}
response = self.client.post(url, json.dumps(body), content_type='application/json')
self.assertEqual(response.status_code, 201)

Expand All @@ -48,7 +48,7 @@ def test_build(self):
self.assertEqual(response.status_code, 201)
formation_id = response.data['id']
# check to see that no initial build was created
url = '/api/formations/{formation_id}/build'.format(**locals())
url = "/api/formations/{formation_id}/build".format(**locals())
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
# post a first build
Expand All @@ -75,7 +75,7 @@ def test_build(self):
'procfile': json.dumps({'web': 'node server.js'}),
'url': 'http://deis.local/slugs/1c52739bbf3a44d3bfb9a58f7bbdd5fb.tar.gz',
'checksum': uuid.uuid4().hex,
}
}
response = self.client.post(url, json.dumps(body), content_type='application/json')
self.assertEqual(response.status_code, 201)
build3 = response.data
Expand Down
4 changes: 2 additions & 2 deletions api/tests/config.py
Expand Up @@ -21,7 +21,7 @@ def setUp(self):
self.assertTrue(
self.client.login(username='autotest', password='password'))
url = '/api/providers'
creds = {'secret_key': 'x'*64, 'access_key': 1*20}
creds = {'secret_key': 'x' * 64, 'access_key': 1 * 20}
body = {'id': 'autotest', 'type': 'mock', 'creds': json.dumps(creds)}
response = self.client.post(url, json.dumps(body), content_type='application/json')
self.assertEqual(response.status_code, 201)
Expand All @@ -42,7 +42,7 @@ def test_config(self):
self.assertEqual(response.status_code, 201)
formation_id = response.data['id']
# check to see that an initial/empty config was created
url = '/api/formations/{formation_id}/config'.format(**locals())
url = "/api/formations/{formation_id}/config".format(**locals())
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertIn('values', response.data)
Expand Down
32 changes: 16 additions & 16 deletions api/tests/container.py
Expand Up @@ -23,8 +23,8 @@ def setUp(self):
self.assertTrue(
self.client.login(username='autotest', password='password'))
url = '/api/providers'
creds = {'access_key': getattr(settings, 'EC2_ACCESS_KEY', 'x'*32),
'secret_key': getattr(settings, 'EC2_SECRET_KEY', 'x'*64)}
creds = {'access_key': getattr(settings, 'EC2_ACCESS_KEY', 'x' * 32),
'secret_key': getattr(settings, 'EC2_SECRET_KEY', 'x' * 64)}
body = {'id': 'autotest', 'type': 'mock', 'creds': json.dumps(creds)}
response = self.client.post(url, json.dumps(body), content_type='application/json')
self.assertEqual(response.status_code, 201)
Expand All @@ -40,62 +40,62 @@ def test_container_scale(self):
response = self.client.post(url, json.dumps(body), content_type='application/json')
self.assertEqual(response.status_code, 201)
formation_id = response.data['id']
url = '/api/formations/{formation_id}/layers'.format(**locals())
url = "/api/formations/{formation_id}/layers".format(**locals())
body = {'id': 'runtime', 'flavor': 'autotest', 'run_list': 'recipe[deis::runtime]'}
response = self.client.post(url, json.dumps(body), content_type='application/json')
self.assertEqual(response.status_code, 201)
# scale runtime layer up
url = '/api/formations/{formation_id}/scale/layers'.format(**locals())
url = "/api/formations/{formation_id}/scale/layers".format(**locals())
body = {'runtime': 4}
response = self.client.post(url, json.dumps(body), content_type='application/json')
self.assertEqual(response.status_code, 200)
url = '/api/formations/{formation_id}/nodes'.format(**locals())
url = "/api/formations/{formation_id}/nodes".format(**locals())
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data['results']), 4)
url = '/api/formations/{formation_id}'.format(**locals())
url = "/api/formations/{formation_id}".format(**locals())
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
# should start with zero
url = '/api/formations/{formation_id}/containers'.format(**locals())
url = "/api/formations/{formation_id}/containers".format(**locals())
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data['results']), 0)
# scale up
url = '/api/formations/{formation_id}/scale/containers'.format(**locals())
url = "/api/formations/{formation_id}/scale/containers".format(**locals())
body = {'web': 4, 'worker': 2}
response = self.client.post(url, json.dumps(body), content_type='application/json')
self.assertEqual(response.status_code, 200)
url = '/api/formations/{formation_id}/containers'.format(**locals())
url = "/api/formations/{formation_id}/containers".format(**locals())
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data['results']), 6)
url = '/api/formations/{formation_id}'.format(**locals())
url = "/api/formations/{formation_id}".format(**locals())
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data['containers'], json.dumps(body))
# scale down
url = '/api/formations/{formation_id}/scale/containers'.format(**locals())
url = "/api/formations/{formation_id}/scale/containers".format(**locals())
body = {'web': 2, 'worker': 1}
response = self.client.post(url, json.dumps(body), content_type='application/json')
url = '/api/formations/{formation_id}/containers'.format(**locals())
url = "/api/formations/{formation_id}/containers".format(**locals())
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data['results']), 3)
url = '/api/formations/{formation_id}'.format(**locals())
url = "/api/formations/{formation_id}".format(**locals())
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data['containers'], json.dumps(body))
# scale down to 0
url = '/api/formations/{formation_id}/scale/containers'.format(**locals())
url = "/api/formations/{formation_id}/scale/containers".format(**locals())
body = {'web': 0, 'worker': 0}
response = self.client.post(url, json.dumps(body), content_type='application/json')
self.assertEqual(response.status_code, 200)
url = '/api/formations/{formation_id}/containers'.format(**locals())
url = "/api/formations/{formation_id}/containers".format(**locals())
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data['results']), 0)
url = '/api/formations/{formation_id}'.format(**locals())
url = "/api/formations/{formation_id}".format(**locals())
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data['containers'], json.dumps(body))
Expand Down

0 comments on commit f79aac9

Please sign in to comment.