@@ -73,16 +73,56 @@ def test_no_prebuilt_dir_falls_back_to_pkg_root(self, mock_find_whl, mock_parsed
7373class TestRunOutputDirectory :
7474 """Verify that dest_dir controls where the output token path ends up."""
7575
76- def _make_args (self , dest_dir = None , generate_md = False ):
76+ def _make_args (self , dest_dir = None , generate_md = False , isolate = False , install_deps = False ):
7777 return argparse .Namespace (
7878 target = "." ,
79- isolate = False ,
79+ isolate = isolate ,
8080 command = "apistub" ,
8181 service = None ,
8282 dest_dir = dest_dir ,
8383 generate_md = generate_md ,
84+ install_deps = install_deps ,
8485 )
8586
87+ @patch (
88+ "azpysdk.apistub.REPO_ROOT" , os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." , ".." ))
89+ )
90+ @patch ("azpysdk.apistub.get_cross_language_mapping_path" , return_value = None )
91+ @patch ("azpysdk.apistub.get_package_wheel_path" , return_value = "/fake/pkg.whl" )
92+ @patch ("azpysdk.apistub.create_package_and_install" )
93+ @patch ("azpysdk.apistub.install_into_venv" )
94+ @patch ("azpysdk.apistub.set_envvar_defaults" )
95+ def test_isolate_installs_dependencies (
96+ self , _env , install_into_venv , _create , _get_whl , _get_mapping , tmp_path , monkeypatch
97+ ):
98+ """When --isolate is passed, apistub should install dependencies."""
99+ monkeypatch .chdir (os .getcwd ())
100+ stub = apistub ()
101+ staging = str (tmp_path / "staging" )
102+ os .makedirs (staging , exist_ok = True )
103+ fake_parsed = MagicMock ()
104+ fake_parsed .folder = str (tmp_path )
105+ fake_parsed .name = "azure-core"
106+
107+ with patch .object (stub , "get_targeted_directories" , return_value = [fake_parsed ]), patch .object (
108+ stub , "get_executable" , return_value = (sys .executable , staging )
109+ ), patch .object (stub , "install_dev_reqs" ) as install_dev_reqs , patch .object (
110+ stub , "pip_freeze"
111+ ) as pip_freeze , patch .object (
112+ stub , "run_venv_command"
113+ ):
114+ args = self ._make_args (isolate = True )
115+ stub .run (args )
116+
117+ install_dev_reqs .assert_called_once_with (sys .executable , args , str (tmp_path ))
118+ install_into_venv .assert_called_once ()
119+ repo_root = os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." , ".." ))
120+ assert install_into_venv .call_args .args [1 ][0 :2 ] == [
121+ "-r" ,
122+ os .path .join (repo_root , "eng" , "apiview_reqs.txt" ),
123+ ]
124+ pip_freeze .assert_called_once_with (sys .executable )
125+
86126 @patch (
87127 "azpysdk.apistub.REPO_ROOT" , os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." , ".." ))
88128 )
0 commit comments