@@ -57,9 +57,11 @@ def test_is_package_installed(mock_distribution):
5757 assert result is False
5858
5959
60+ @mock .patch ("cumulusci.cli.robot.shutil.which" )
6061@mock .patch ("cumulusci.cli.robot.sarge" )
61- def test_happy_path (sarge ):
62+ def test_happy_path (sarge , which ):
6263 """Verify the happy path is indeed happy"""
64+ which .return_value = False
6365 sarge .Command .side_effect = mock_Command ()
6466 with mock .patch ("cumulusci.cli.robot._is_package_installed" , return_value = False ):
6567 run_cli_command ("robot" , "install_playwright" )
@@ -80,6 +82,30 @@ def test_happy_path(sarge):
8082 assert actual_calls == expected_calls , msg
8183
8284
85+ @mock .patch ("cumulusci.cli.robot.shutil.which" )
86+ @mock .patch ("cumulusci.cli.robot.sarge" )
87+ def test_happy_path_uv (sarge , which ):
88+ """Verify the happy path is indeed happy with uv"""
89+ which .return_value = True
90+ sarge .Command .side_effect = mock_Command ()
91+ with mock .patch ("cumulusci.cli.robot._is_package_installed" , return_value = False ):
92+ run_cli_command ("robot" , "install_playwright" )
93+ actual_calls = [call .args [0 ] for call in sarge .Command .mock_calls ]
94+ expected_calls = [
95+ "npm --version" ,
96+ [
97+ "uv" ,
98+ "pip" ,
99+ "install" ,
100+ "robotframework-browser" ,
101+ ],
102+ [sys .executable , "-m" , "Browser.entry" , "init" ],
103+ ]
104+ msg = f"\n -- expected --\n { expected_calls } \n \n -- actual --\n { actual_calls } "
105+
106+ assert actual_calls == expected_calls , msg
107+
108+
83109@mock .patch ("sys.exit" )
84110def test_bogus_subcommand (sys_exit ):
85111 """Verify a bogus subcommand returns a UsageError"""
@@ -100,9 +126,11 @@ def test_no_npm(sarge):
100126 assert sarge .Command .mock_calls [0 ].args [0 ] == "npm --version"
101127
102128
129+ @mock .patch ("cumulusci.cli.robot.shutil.which" )
103130@mock .patch ("cumulusci.cli.robot.sarge" )
104- def test_playwright_dry_run (sarge ):
131+ def test_playwright_dry_run (sarge , which ):
105132 """Verify the output of a dry run"""
133+ which .return_value = False
106134 sarge .Command .side_effect = mock_Command (returncodes = {"npm --version" : 0 })
107135 with mock .patch ("cumulusci.cli.robot._is_package_installed" , return_value = False ):
108136 result = run_cli_command ("robot" , "install_playwright" , "--dry_run" )
@@ -130,9 +158,11 @@ def test_playwright_failure_to_initialize_browser_library(sarge):
130158 run_cli_command ("robot" , "install_playwright" )
131159
132160
161+ @mock .patch ("cumulusci.cli.robot.shutil.which" )
133162@mock .patch ("cumulusci.cli.robot.sarge" )
134- def test_playwright_failure_to_install_browser_library (sarge ):
163+ def test_playwright_failure_to_install_browser_library (sarge , which ):
135164 """Verify we raise an exception if we can't install playwright"""
165+ which .return_value = False
136166 cmd = str ([sys .executable , "-m" , "pip" , "install" , "robotframework-browser" ])
137167 sarge .Command .side_effect = mock_Command (returncodes = {cmd : 1 })
138168 with mock .patch ("cumulusci.cli.robot._is_package_installed" , return_value = False ):
@@ -154,9 +184,11 @@ def test_playwright_already_installed(sarge):
154184 )
155185
156186
187+ @mock .patch ("cumulusci.cli.robot.shutil.which" )
157188@mock .patch ("cumulusci.cli.robot.sarge" )
158- def test_uninstall_playwright (sarge ):
189+ def test_uninstall_playwright (sarge , which ):
159190 """Verify calling 'robot uninstall_playwright' calls the right utilities"""
191+ which .return_value = False
160192 sarge .Command .side_effect = mock_Command ()
161193 with mock .patch ("cumulusci.cli.robot._is_package_installed" , return_value = False ):
162194 run_cli_command ("robot" , "uninstall_playwright" )
0 commit comments