11from unittest import TestCase
2- from unittest .mock import Mock , patch
2+ from unittest .mock import Mock , patch , call
33import json
44
55import httpretty
@@ -332,6 +332,7 @@ def test_prepare_redeploy(self):
332332 app_mode = AppModes .PYTHON_SHINY
333333
334334 self .cloud_client .get_content .return_value = {"id" : 1 , "source_id" : 10 , "url" : "https://posit.cloud/content/1" }
335+ self .cloud_client .get_application .return_value = {"id" : 10 , "content_id" : 200 }
335336 self .cloud_client .create_bundle .return_value = {
336337 "id" : 100 ,
337338 "presigned_url" : "https://presigned.url" ,
@@ -348,6 +349,7 @@ def test_prepare_redeploy(self):
348349 )
349350 self .cloud_client .get_content .assert_called_with (1 )
350351 self .cloud_client .create_bundle .assert_called_with (10 , "application/x-tar" , bundle_size , bundle_hash )
352+ self .cloud_client .update_output .assert_called_with (1 , {"project" : 200 })
351353
352354 assert prepare_deploy_result .app_id == 1
353355 assert prepare_deploy_result .application_id == 10
@@ -364,6 +366,7 @@ def test_prepare_redeploy_static(self):
364366 app_mode = AppModes .STATIC
365367
366368 self .cloud_client .get_content .return_value = {"id" : 1 , "source_id" : 10 , "url" : "https://posit.cloud/content/1" }
369+ self .cloud_client .get_application .return_value = {"id" : 10 , "content_id" : 200 }
367370 self .cloud_client .create_revision .return_value = {
368371 "application_id" : 11 ,
369372 }
@@ -384,6 +387,7 @@ def test_prepare_redeploy_static(self):
384387 self .cloud_client .get_content .assert_called_with (1 )
385388 self .cloud_client .create_revision .assert_called_with (1 )
386389 self .cloud_client .create_bundle .assert_called_with (11 , "application/x-tar" , bundle_size , bundle_hash )
390+ self .cloud_client .update_output .assert_called_with (1 , {"project" : 200 })
387391
388392 assert prepare_deploy_result .app_id == 1
389393 assert prepare_deploy_result .application_id == 11
@@ -418,9 +422,11 @@ def test_prepare_redeploy_preversioned_app_store(self):
418422 app_mode = app_mode ,
419423 app_store_version = None ,
420424 )
421- self .cloud_client .get_application .assert_called_with (10 )
425+ # first call is to get the current project id, second call is to get the application
426+ self .cloud_client .get_application .assert_has_calls ([call (self .project_application_id ), call (app_id )])
422427 self .cloud_client .get_content .assert_called_with (1 )
423428 self .cloud_client .create_bundle .assert_called_with (10 , "application/x-tar" , bundle_size , bundle_hash )
429+ self .cloud_client .update_output .assert_called_with (1 , {"project" : 1 })
424430
425431 assert prepare_deploy_result .app_id == 1
426432 assert prepare_deploy_result .application_id == 10
0 commit comments