@@ -333,3 +333,43 @@ def json(self):
333333 body = {'version' : 2 }
334334 response = self .client .post (url , body )
335335 self .assertEqual (response .status_code , 400 , response .data )
336+
337+ def test_release_unset_config (self , mock_requests ):
338+ """
339+ Test that a release is created when an app is created, a config can be
340+ set and then unset without causing a 409 (conflict)
341+ """
342+ url = '/v2/apps'
343+ response = self .client .post (url )
344+ self .assertEqual (response .status_code , 201 , response .data )
345+ app_id = response .data ['id' ]
346+
347+ # check that updating config rolls a new release
348+ url = '/v2/apps/{app_id}/config' .format (** locals ())
349+ body = {'cpu' : json .dumps ({'cmd' : None })}
350+ response = self .client .post (url , body )
351+ self .assertEqual (response .status_code , 422 , response .data )
352+
353+ def test_release_no_change (self , mock_requests ):
354+ """
355+ Test that a release is created when an app is created, and
356+ then has 2 identical config set, causing a 409 as there was
357+ no change
358+ """
359+ url = '/v2/apps'
360+ response = self .client .post (url )
361+ self .assertEqual (response .status_code , 201 , response .data )
362+ app_id = response .data ['id' ]
363+
364+ # check that updating config rolls a new release
365+ url = '/v2/apps/{app_id}/config' .format (** locals ())
366+ body = {'values' : json .dumps ({'NEW_URL1' : 'http://localhost:8080/' })}
367+ response = self .client .post (url , body )
368+ self .assertEqual (response .status_code , 201 , response .data )
369+ self .assertIn ('NEW_URL1' , response .data ['values' ])
370+
371+ # trigger identical release
372+ url = '/v2/apps/{app_id}/config' .format (** locals ())
373+ body = {'values' : json .dumps ({'NEW_URL1' : 'http://localhost:8080/' })}
374+ response = self .client .post (url , body )
375+ self .assertEqual (response .status_code , 409 , response .data )
0 commit comments