@@ -34,23 +34,20 @@ def setUp(self):
3434 response = self .client .post (url , json .dumps (body ), content_type = 'application/json' )
3535 self .assertEqual (response .status_code , 201 )
3636 formation_id = 'autotest'
37- response = self .client .post ('/api/formations' , json .dumps (
38- {'id' : formation_id , 'domain' : 'localhost.localdomain' }),
39- content_type = 'application/json' )
37+ response = self .client .post ('/api/formations' , json .dumps ({'id' : formation_id }),
38+ content_type = 'application/json' )
4039 self .assertEqual (response .status_code , 201 )
4140 # create & scale a basic formation
4241 url = '/api/formations/{formation_id}/layers' .format (** locals ())
43- body = {'id' : 'proxy' , 'flavor' : 'autotest' , 'proxy' : True ,
44- 'run_list' : 'recipe[deis::proxy]' }
42+ body = {'id' : 'proxy' , 'flavor' : 'autotest' , 'proxy' : True }
4543 response = self .client .post (url , json .dumps (body ), content_type = 'application/json' )
4644 self .assertEqual (response .status_code , 201 )
4745 url = '/api/formations/{formation_id}/layers' .format (** locals ())
48- body = {'id' : 'runtime' , 'flavor' : 'autotest' , 'runtime' : True ,
49- 'run_list' : 'recipe[deis::proxy]' }
46+ body = {'id' : 'runtime' , 'flavor' : 'autotest' , 'runtime' : True }
5047 response = self .client .post (url , json .dumps (body ), content_type = 'application/json' )
5148 self .assertEqual (response .status_code , 201 )
5249 url = '/api/formations/{formation_id}/scale' .format (** locals ())
53- body = {'proxy' : 2 , 'runtime' : 4 }
50+ body = {'proxy' : 1 , 'runtime' : 2 }
5451 response = self .client .post (url , json .dumps (body ), content_type = 'application/json' )
5552 self .assertEqual (response .status_code , 200 )
5653
@@ -112,6 +109,42 @@ def test_app_override_id(self):
112109 self .assertContains (response , 'App with this Id already exists.' , status_code = 400 )
113110 return response
114111
112+ def test_multiple_apps (self ):
113+ url = '/api/apps'
114+ body = {'formation' : 'autotest' }
115+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' )
116+ self .assertEqual (response .status_code , 201 )
117+ app1_id = response .data ['id' ]
118+ # test single app domain
119+ url = "/api/apps/{app1_id}/calculate" .format (** locals ())
120+ response = self .client .post (url )
121+ self .assertEqual (response .status_code , 200 )
122+ self .assertEqual (response .data ['domains' ], ['localhost.localdomain.local' ])
123+ # create second app without multi-app support
124+ url = '/api/apps'
125+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' )
126+ self .assertContains (response , 'Formation does not support multiple apps' , status_code = 400 )
127+ # add domain for multi-app support
128+ url = '/api/formations/autotest'
129+ response = self .client .patch (url , json .dumps ({'domain' : 'deisapp.local' }),
130+ content_type = 'application/json' )
131+ self .assertEqual (response .status_code , 200 )
132+ # create second app
133+ url = '/api/apps'
134+ body = {'formation' : 'autotest' }
135+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' )
136+ self .assertEqual (response .status_code , 201 )
137+ app2_id = response .data ['id' ]
138+ # test multiple app domains
139+ url = "/api/apps/{app1_id}/calculate" .format (** locals ())
140+ response = self .client .post (url )
141+ self .assertEqual (response .status_code , 200 )
142+ self .assertEqual (response .data ['domains' ], ['{}.deisapp.local' .format (app1_id )])
143+ url = "/api/apps/{app2_id}/calculate" .format (** locals ())
144+ response = self .client .post (url )
145+ self .assertEqual (response .status_code , 200 )
146+ self .assertEqual (response .data ['domains' ], ['{}.deisapp.local' .format (app2_id )])
147+
115148 def test_app_actions (self ):
116149 url = '/api/apps'
117150 body = {'formation' : 'autotest' , 'id' : 'autotest' }
0 commit comments