@@ -111,6 +111,34 @@ def test_app_override_id(self):
111111 self .assertContains (response , 'App with this Id already exists.' , status_code = 400 )
112112 return response
113113
114+ def test_app_default_formation (self ):
115+ # delete formation created in setUp
116+ response = self .client .delete ('/api/formations/autotest' )
117+ self .assertEqual (response .status_code , 204 )
118+ # try creating an app with no formation specified
119+ url = '/api/apps'
120+ response = self .client .post (url )
121+ self .assertContains (response , 'No formations available' , status_code = 400 )
122+ # create a formation
123+ formation1 = 'autotest'
124+ response = self .client .post ('/api/formations' , json .dumps ({'id' : formation1 }),
125+ content_type = 'application/json' )
126+ self .assertEqual (response .status_code , 201 )
127+ # try again to create an app with no formation specified
128+ url = '/api/apps'
129+ response = self .client .post (url )
130+ self .assertEqual (response .status_code , 201 )
131+ self .assertEqual (formation1 , response .data ['formation' ])
132+ # create a second formation
133+ formation2 = 'autotest2'
134+ response = self .client .post ('/api/formations' , json .dumps ({'id' : formation2 }),
135+ content_type = 'application/json' )
136+ self .assertEqual (response .status_code , 201 )
137+ # create another app with no formation specified
138+ url = '/api/apps'
139+ response = self .client .post (url )
140+ self .assertContains (response , 'Could not determine default formation' , status_code = 400 )
141+
114142 def test_multiple_apps (self ):
115143 url = '/api/apps'
116144 body = {'formation' : 'autotest' }
0 commit comments