@@ -413,6 +413,10 @@ def test_create_bicep_deployment_group_with_enum(monkeypatch):
413413 mock_open_func = mock_open ()
414414 monkeypatch .setattr (builtins , 'open' , mock_open_func )
415415 monkeypatch .setattr (builtins , 'print' , MagicMock ())
416+ # Mock os functions for file path operations
417+ monkeypatch .setattr ('os.getcwd' , MagicMock (return_value = '/test/dir' ))
418+ monkeypatch .setattr ('os.path.exists' , MagicMock (return_value = True ))
419+ monkeypatch .setattr ('os.path.basename' , MagicMock (return_value = 'test-dir' ))
416420
417421 bicep_params = {'param1' : {'value' : 'test' }}
418422 rg_tags = {'infrastructure' : 'simple-apim' }
@@ -440,6 +444,10 @@ def test_create_bicep_deployment_group_with_string(monkeypatch):
440444 mock_open_func = mock_open ()
441445 monkeypatch .setattr (builtins , 'open' , mock_open_func )
442446 monkeypatch .setattr (builtins , 'print' , MagicMock ())
447+ # Mock os functions for file path operations
448+ monkeypatch .setattr ('os.getcwd' , MagicMock (return_value = '/test/dir' ))
449+ monkeypatch .setattr ('os.path.exists' , MagicMock (return_value = True ))
450+ monkeypatch .setattr ('os.path.basename' , MagicMock (return_value = 'test-dir' ))
443451
444452 bicep_params = {'param1' : {'value' : 'test' }}
445453
@@ -464,6 +472,10 @@ def test_create_bicep_deployment_group_params_file_written(monkeypatch):
464472 mock_open_func = mock_open ()
465473 monkeypatch .setattr (builtins , 'open' , mock_open_func )
466474 monkeypatch .setattr (builtins , 'print' , MagicMock ())
475+ # Mock os functions for file path operations
476+ monkeypatch .setattr ('os.getcwd' , MagicMock (return_value = '/test/dir' ))
477+ monkeypatch .setattr ('os.path.exists' , MagicMock (return_value = True ))
478+ monkeypatch .setattr ('os.path.basename' , MagicMock (return_value = 'test-dir' ))
467479
468480 bicep_params = {
469481 'apiManagementName' : {'value' : 'test-apim' },
@@ -474,8 +486,9 @@ def test_create_bicep_deployment_group_params_file_written(monkeypatch):
474486 'test-rg' , 'eastus' , INFRASTRUCTURE .APIM_ACA , bicep_params , 'custom-params.json'
475487 )
476488
477- # Verify file was opened for writing
478- mock_open_func .assert_called_once_with ('custom-params.json' , 'w' )
489+ # Verify file was opened for writing with resolved infrastructure path
490+ expected_path = os .path .join ('/test/dir' , 'infrastructure' , 'apim-aca' , 'custom-params.json' )
491+ mock_open_func .assert_called_once_with (expected_path , 'w' )
479492
480493 # Verify the correct JSON structure was written
481494 written_content = '' .join (call .args [0 ] for call in mock_open_func ().write .call_args_list )
@@ -495,7 +508,11 @@ def test_create_bicep_deployment_group_no_tags(monkeypatch):
495508 mock_open_func = mock_open ()
496509 monkeypatch .setattr (builtins , 'open' , mock_open_func )
497510 monkeypatch .setattr (builtins , 'print' , MagicMock ())
498-
511+ # Mock os functions for file path operations
512+ monkeypatch .setattr ('os.getcwd' , MagicMock (return_value = '/test/dir' ))
513+ monkeypatch .setattr ('os.path.exists' , MagicMock (return_value = True ))
514+ monkeypatch .setattr ('os.path.basename' , MagicMock (return_value = 'test-dir' ))
515+
499516 bicep_params = {'param1' : {'value' : 'test' }}
500517
501518 utils .create_bicep_deployment_group ('test-rg' , 'eastus' , 'test-deployment' , bicep_params )
@@ -512,7 +529,11 @@ def test_create_bicep_deployment_group_deployment_failure(monkeypatch):
512529 mock_open_func = mock_open ()
513530 monkeypatch .setattr (builtins , 'open' , mock_open_func )
514531 monkeypatch .setattr (builtins , 'print' , MagicMock ())
515-
532+ # Mock os functions for file path operations
533+ monkeypatch .setattr ('os.getcwd' , MagicMock (return_value = '/test/dir' ))
534+ monkeypatch .setattr ('os.path.exists' , MagicMock (return_value = True ))
535+ monkeypatch .setattr ('os.path.basename' , MagicMock (return_value = 'test-dir' ))
536+
516537 bicep_params = {'param1' : {'value' : 'test' }}
517538
518539 result = utils .create_bicep_deployment_group ('test-rg' , 'eastus' , 'test-deployment' , bicep_params )
@@ -571,6 +592,12 @@ def test_create_bicep_deployment_group_success(monkeypatch):
571592 mock_output = MagicMock (success = True , json_data = {"id" : "deployment-id" })
572593 monkeypatch .setattr (utils , 'run' , lambda * a , ** kw : mock_output )
573594 monkeypatch .setattr (utils , 'does_resource_group_exist' , lambda x : True )
595+ # Mock os functions for file path operations
596+ monkeypatch .setattr ('os.getcwd' , MagicMock (return_value = '/test/dir' ))
597+ monkeypatch .setattr ('os.path.exists' , MagicMock (return_value = True ))
598+ monkeypatch .setattr ('os.path.basename' , MagicMock (return_value = 'test-dir' ))
599+ mock_open_func = mock_open ()
600+ monkeypatch .setattr (builtins , 'open' , mock_open_func )
574601
575602 result = utils .create_bicep_deployment_group (
576603 "test-rg" , "eastus" , INFRASTRUCTURE .SIMPLE_APIM , {"param1" : "value1" }
@@ -583,6 +610,12 @@ def test_create_bicep_deployment_group_creates_rg(monkeypatch):
583610 monkeypatch .setattr (utils , 'run' , lambda * a , ** kw : mock_output )
584611 monkeypatch .setattr (utils , 'does_resource_group_exist' , lambda x : False )
585612 monkeypatch .setattr (utils , 'create_resource_group' , lambda * a , ** kw : None )
613+ # Mock os functions for file path operations
614+ monkeypatch .setattr ('os.getcwd' , MagicMock (return_value = '/test/dir' ))
615+ monkeypatch .setattr ('os.path.exists' , MagicMock (return_value = True ))
616+ monkeypatch .setattr ('os.path.basename' , MagicMock (return_value = 'test-dir' ))
617+ mock_open_func = mock_open ()
618+ monkeypatch .setattr (builtins , 'open' , mock_open_func )
586619
587620 result = utils .create_bicep_deployment_group (
588621 "test-rg" , "eastus" , INFRASTRUCTURE .SIMPLE_APIM , {"param1" : "value1" }
0 commit comments