@@ -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 )
0 commit comments