Skip to content

Commit d045377

Browse files
author
Gabriel Monroy
committed
add Build.push test coverage
1 parent f306aad commit d045377

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

api/models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,9 @@ def publish(self):
459459
return data
460460

461461
def converge(self):
462-
self.publish()
462+
databag = self.publish()
463463
self.formation.converge()
464+
return databag
464465

465466
def calculate(self):
466467
"""Return a representation for configuration management"""
@@ -709,8 +710,8 @@ def push(cls, push):
709710
len(app.formation.container_set.filter(type='web')) < 1:
710711
# scale an initial web containers
711712
Container.objects.scale(app, {'web': 1})
712-
# publish the app, triggering a formation converge
713-
return app.publish()
713+
# publish and converge the application
714+
return app.converge()
714715

715716

716717
@python_2_unicode_compatible

api/tests/build.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
from django.test import TestCase
1313

14+
from api.models import Build
15+
1416
# pylint: disable=R0904
1517

1618

@@ -93,3 +95,14 @@ def test_build(self):
9395
self.assertEqual(self.client.put(url).status_code, 405)
9496
self.assertEqual(self.client.patch(url).status_code, 405)
9597
self.assertEqual(self.client.delete(url).status_code, 405)
98+
99+
def test_build_push(self):
100+
url = '/api/apps'
101+
body = {'formation': 'autotest'}
102+
response = self.client.post(url, json.dumps(body), content_type='application/json')
103+
self.assertEqual(response.status_code, 201)
104+
app_id = response.data['id']
105+
# simulate a git push calling Build.push()
106+
push = {'username': 'autotest', 'app': app_id}
107+
databag = Build.push(push)
108+
self.assertIn('release', databag)

0 commit comments

Comments
 (0)