Skip to content

Commit 64deec5

Browse files
author
Gabriel Monroy
committed
allow listing of builds/releases
1 parent 9a04b32 commit 64deec5

3 files changed

Lines changed: 22 additions & 27 deletions

File tree

api/tests/build.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ 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}/builds".format(**locals())
5252
response = self.client.get(url)
53-
self.assertEqual(response.status_code, 404)
53+
self.assertEqual(response.status_code, 200)
54+
self.assertEqual(response.data['count'], 0)
5455
# post a first build
5556
body = {
5657
'sha': uuid.uuid4().hex,
@@ -61,14 +62,17 @@ def test_build(self):
6162
}
6263
response = self.client.post(url, json.dumps(body), content_type='application/json')
6364
self.assertEqual(response.status_code, 201)
65+
build_id = response.data['uuid']
6466
build1 = response.data
6567
self.assertEqual(response.data['url'], body['url'])
6668
# read the build
69+
url = "/api/formations/{formation_id}/builds/{build_id}".format(**locals())
6770
response = self.client.get(url)
6871
self.assertEqual(response.status_code, 200)
6972
build2 = response.data
7073
self.assertEqual(build1, build2)
7174
# post a new build
75+
url = "/api/formations/{formation_id}/builds".format(**locals())
7276
body = {
7377
'sha': uuid.uuid4().hex,
7478
'slug_size': 4096000,

api/tests/release.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ def test_release(self):
5151
self.assertEqual(response.status_code, 201)
5252
formation_id = response.data['id'] # noqa
5353
# check to see that an initial release was created
54-
url = '/api/formations/{formation_id}/release'.format(**locals())
54+
url = '/api/formations/{formation_id}/releases'.format(**locals())
55+
response = self.client.get(url)
56+
self.assertEqual(response.status_code, 200)
57+
self.assertEqual(response.data['count'], 1)
58+
url = '/api/formations/{formation_id}/releases/1'.format(**locals())
5559
response = self.client.get(url)
5660
self.assertEqual(response.status_code, 200)
5761
release1 = response.data
@@ -67,7 +71,7 @@ def test_release(self):
6771
self.assertEqual(response.status_code, 201)
6872
self.assertIn('NEW_URL1', json.loads(response.data['values']))
6973
# check to see that a new release was created
70-
url = '/api/formations/{formation_id}/release'.format(**locals())
74+
url = '/api/formations/{formation_id}/releases/2'.format(**locals())
7175
response = self.client.get(url)
7276
self.assertEqual(response.status_code, 200)
7377
release2 = response.data
@@ -77,7 +81,7 @@ def test_release(self):
7781
self.assertEqual(release1['build'], release2['build'])
7882
self.assertEquals(release2['version'], 2)
7983
# check that updating the build rolls a new release
80-
url = '/api/formations/{formation_id}/build'.format(**locals())
84+
url = '/api/formations/{formation_id}/builds'.format(**locals())
8185
build_config = json.dumps({'PATH': 'bin:/usr/local/bin:/usr/bin:/bin'})
8286
body = {
8387
'sha': uuid.uuid4().hex,
@@ -92,7 +96,7 @@ def test_release(self):
9296
self.assertEqual(response.status_code, 201)
9397
self.assertEqual(response.data['url'], body['url'])
9498
# check to see that a new release was created
95-
url = '/api/formations/{formation_id}/release'.format(**locals())
99+
url = '/api/formations/{formation_id}/releases/3'.format(**locals())
96100
response = self.client.get(url)
97101
self.assertEqual(response.status_code, 200)
98102
release3 = response.data
@@ -110,23 +114,8 @@ def test_release(self):
110114
self.assertIn('PATH', config3_values)
111115
self.assertEqual(
112116
config3_values['PATH'], 'bin:/usr/local/bin:/usr/bin:/bin')
113-
# check that updating the image rolls a new release
114-
url = '/api/formations/{formation_id}/image'.format(**locals())
115-
body = {'image': 'deis/autotest2'}
116-
response = self.client.post(
117-
url, json.dumps(body), content_type='application/json')
118-
self.assertEqual(response.status_code, 201)
119-
# check to see that a new release was created
120-
url = '/api/formations/{formation_id}/release'.format(**locals())
121-
response = self.client.get(url)
122-
self.assertEqual(response.status_code, 200)
123-
release4 = response.data
124-
self.assertNotEqual(release3['uuid'], release4['uuid'])
125-
self.assertNotEqual(release3['image'], release4['image'])
126-
self.assertEqual(release3['build'], release4['build'])
127-
self.assertEqual(release3['config'], release4['config'])
128-
self.assertEquals(release4['version'], 4)
129117
# disallow post/put/patch/delete
118+
url = '/api/formations/{formation_id}/releases'.format(**locals())
130119
self.assertEqual(self.client.post(url).status_code, 405)
131120
self.assertEqual(self.client.put(url).status_code, 405)
132121
self.assertEqual(self.client.patch(url).status_code, 405)

api/urls.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@
5555
# formation release components
5656
url(r'^formations/(?P<id>[a-z0-9-]+)/config/?',
5757
views.FormationConfigViewSet.as_view({'post': 'create', 'get': 'retrieve'})),
58-
url(r'^formations/(?P<id>[a-z0-9-]+)/image/?',
59-
views.FormationImageViewSet.as_view({'post': 'reset_image'})),
60-
url(r'^formations/(?P<id>[a-z0-9-]+)/build/?',
61-
views.FormationBuildViewSet.as_view({'post': 'create', 'get': 'retrieve'})),
62-
url(r'^formations/(?P<id>[a-z0-9-]+)/release/?',
58+
url(r'^formations/(?P<id>[a-z0-9-]+)/builds/(?P<uuid>[a-z0-9-]+)/?',
59+
views.FormationBuildViewSet.as_view({'get': 'retrieve'})),
60+
url(r'^formations/(?P<id>[a-z0-9-]+)/builds/?',
61+
views.FormationBuildViewSet.as_view({'post': 'create', 'get': 'list'})),
62+
url(r'^formations/(?P<id>[a-z0-9-]+)/releases/(?P<version>[0-9]+)/?',
6363
views.FormationReleaseViewSet.as_view({'get': 'retrieve'})),
64+
url(r'^formations/(?P<id>[a-z0-9-]+)/releases/?',
65+
views.FormationReleaseViewSet.as_view({'get': 'list'})),
6466
# formation actions
6567
url(r'^formations/(?P<id>[a-z0-9-]+)/scale/layers/?',
6668
views.FormationViewSet.as_view({'post': 'scale_layers'})),

0 commit comments

Comments
 (0)