Skip to content

Commit 5710ccb

Browse files
author
Gabriel Monroy
committed
fix(flake8): resolve code formatting issues
1 parent f680df6 commit 5710ccb

2 files changed

Lines changed: 52 additions & 11 deletions

File tree

controller/api/tests/test_build.py

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,11 @@ def test_build_default_containers(self):
7777
response = self.client.post(url, json.dumps(body), content_type='application/json')
7878
self.assertEqual(response.status_code, 201)
7979
app_id = response.data['id']
80-
# post a new build
80+
# post an image as a build
8181
url = "/api/apps/{app_id}/builds".format(**locals())
8282
body = {'image': 'autotest/example'}
8383
response = self.client.post(url, json.dumps(body), content_type='application/json')
8484
self.assertEqual(response.status_code, 201)
85-
# test default container
8685
url = "/api/apps/{app_id}/containers/cmd".format(**locals())
8786
response = self.client.get(url)
8887
self.assertEqual(response.status_code, 200)
@@ -98,11 +97,53 @@ def test_build_default_containers(self):
9897
app_id = response.data['id']
9998
# post a new build with procfile
10099
url = "/api/apps/{app_id}/builds".format(**locals())
101-
body = {'image': 'autotest/example', 'procfile': json.dumps({'web': 'node server.js',
102-
'worker': 'node worker.js'})}
100+
body = {'image': 'autotest/example',
101+
'sha': 'a'*40,
102+
'dockerfile': "FROM scratch"}
103+
response = self.client.post(url, json.dumps(body), content_type='application/json')
104+
self.assertEqual(response.status_code, 201)
105+
url = "/api/apps/{app_id}/containers/cmd".format(**locals())
106+
response = self.client.get(url)
107+
self.assertEqual(response.status_code, 200)
108+
self.assertEqual(len(response.data['results']), 1)
109+
container = response.data['results'][0]
110+
self.assertEqual(container['type'], 'cmd')
111+
self.assertEqual(container['num'], 1)
112+
# start with a new app
113+
url = '/api/apps'
114+
body = {'cluster': 'autotest'}
115+
response = self.client.post(url, json.dumps(body), content_type='application/json')
116+
self.assertEqual(response.status_code, 201)
117+
app_id = response.data['id']
118+
# post a new build with procfile
119+
url = "/api/apps/{app_id}/builds".format(**locals())
120+
body = {'image': 'autotest/example',
121+
'sha': 'a'*40,
122+
'dockerfile': "FROM scratch",
123+
'procfile': {'worker': 'node worker.js'}}
124+
response = self.client.post(url, json.dumps(body), content_type='application/json')
125+
self.assertEqual(response.status_code, 201)
126+
url = "/api/apps/{app_id}/containers/cmd".format(**locals())
127+
response = self.client.get(url)
128+
self.assertEqual(response.status_code, 200)
129+
self.assertEqual(len(response.data['results']), 1)
130+
container = response.data['results'][0]
131+
self.assertEqual(container['type'], 'cmd')
132+
self.assertEqual(container['num'], 1)
133+
# start with a new app
134+
url = '/api/apps'
135+
body = {'cluster': 'autotest'}
136+
response = self.client.post(url, json.dumps(body), content_type='application/json')
137+
self.assertEqual(response.status_code, 201)
138+
app_id = response.data['id']
139+
# post a new build with procfile
140+
url = "/api/apps/{app_id}/builds".format(**locals())
141+
body = {'image': 'autotest/example',
142+
'sha': 'a'*40,
143+
'procfile': json.dumps({'web': 'node server.js',
144+
'worker': 'node worker.js'})}
103145
response = self.client.post(url, json.dumps(body), content_type='application/json')
104146
self.assertEqual(response.status_code, 201)
105-
# test listing/retrieving container info
106147
url = "/api/apps/{app_id}/containers/web".format(**locals())
107148
response = self.client.get(url)
108149
self.assertEqual(response.status_code, 200)

controller/api/tests/test_container.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ def test_container_api_heroku(self):
122122
self.assertEqual(len(response.data['results']), 0)
123123
# post a new build
124124
url = "/api/apps/{app_id}/builds".format(**locals())
125-
body = {'image': 'autotest/example', 'procfile': json.dumps({'web': 'node server.js',
126-
'worker': 'node worker.js'})}
125+
body = {'image': 'autotest/example', 'sha': 'a'*40,
126+
'procfile': json.dumps({'web': 'node server.js', 'worker': 'node worker.js'})}
127127
response = self.client.post(url, json.dumps(body), content_type='application/json')
128128
self.assertEqual(response.status_code, 201)
129129
# scale up
@@ -246,8 +246,8 @@ def test_container_release(self):
246246
self.assertEqual(len(response.data['results']), 0)
247247
# post a new build
248248
url = "/api/apps/{app_id}/builds".format(**locals())
249-
body = {'image': 'autotest/example', 'procfile': json.dumps({'web': 'node server.js',
250-
'worker': 'node worker.js'})}
249+
body = {'image': 'autotest/example', 'sha': 'a'*40,
250+
'procfile': json.dumps({'web': 'node server.js', 'worker': 'node worker.js'})}
251251
response = self.client.post(url, json.dumps(body), content_type='application/json')
252252
self.assertEqual(response.status_code, 201)
253253
# scale up
@@ -305,8 +305,8 @@ def test_container_str(self):
305305
app_id = response.data['id']
306306
# post a new build
307307
url = "/api/apps/{app_id}/builds".format(**locals())
308-
body = {'image': 'autotest/example', 'procfile': json.dumps({'web': 'node server.js',
309-
'worker': 'node worker.js'})}
308+
body = {'image': 'autotest/example', 'sha': 'a'*40,
309+
'procfile': json.dumps({'web': 'node server.js', 'worker': 'node worker.js'})}
310310
response = self.client.post(url, json.dumps(body), content_type='application/json')
311311
self.assertEqual(response.status_code, 201)
312312
# scale up

0 commit comments

Comments
 (0)