99
1010import pytest
1111
12- from pybricksdev .cli import Download , Tool
12+ from pybricksdev .cli import Run , Tool
1313
1414
1515class TestTool :
@@ -21,7 +21,7 @@ def test_is_abstract(self):
2121 Tool ()
2222
2323
24- class TestDownload :
24+ class TestRun :
2525 """Tests for the Download command."""
2626
2727 def test_add_parser (self ):
@@ -31,13 +31,13 @@ def test_add_parser(self):
3131 subparsers = parser .add_subparsers ()
3232
3333 # Add the download command
34- download = Download ()
35- download .add_parser (subparsers )
34+ run = Run ()
35+ run .add_parser (subparsers )
3636
3737 # Verify the parser was created with correct arguments
38- assert "download " in subparsers .choices
39- parser = subparsers .choices ["download " ]
40- assert parser .tool is download
38+ assert "run " in subparsers .choices
39+ parser = subparsers .choices ["run " ]
40+ assert parser .tool is run
4141
4242 # Test that required arguments are present
4343 mock_file = mock_open (read_data = "print('test')" )
@@ -82,6 +82,8 @@ async def test_download_ble(self):
8282 conntype = "ble" ,
8383 file = open (temp_path , "r" ),
8484 name = "MyHub" ,
85+ start = False ,
86+ wait = False ,
8587 )
8688
8789 mock_hub_class = stack .enter_context (
@@ -95,8 +97,8 @@ async def test_download_ble(self):
9597 )
9698
9799 # Run the command
98- download = Download ()
99- await download .run (args )
100+ run = Run ()
101+ await run .run (args )
100102
101103 # Verify the hub was created and used correctly
102104 mock_hub_class .assert_called_once_with ("mock_device" )
@@ -127,6 +129,8 @@ async def test_download_usb(self):
127129 conntype = "usb" ,
128130 file = open (temp_path , "r" ),
129131 name = None ,
132+ start = False ,
133+ wait = False ,
130134 )
131135
132136 mock_hub_class = stack .enter_context (
@@ -138,8 +142,8 @@ async def test_download_usb(self):
138142 stack .enter_context (patch ("usb.core.find" , return_value = "mock_device" ))
139143
140144 # Run the command
141- download = Download ()
142- await download .run (args )
145+ run = Run ()
146+ await run .run (args )
143147
144148 # Verify the hub was created and used correctly
145149 mock_hub_class .assert_called_once_with ("mock_device" )
@@ -165,6 +169,8 @@ async def test_download_stdin(self):
165169 conntype = "ble" ,
166170 file = mock_stdin ,
167171 name = "MyHub" ,
172+ start = False ,
173+ wait = False ,
168174 )
169175
170176 # Set up mocks using ExitStack
@@ -182,8 +188,8 @@ async def test_download_stdin(self):
182188 mock_temp .return_value .__enter__ .return_value .name = "/tmp/test.py"
183189
184190 # Run the command
185- download = Download ()
186- await download .run (args )
191+ run = Run ()
192+ await run .run (args )
187193
188194 # Verify the hub was created and used correctly
189195 mock_hub_class .assert_called_once_with ("mock_device" )
@@ -213,6 +219,8 @@ async def test_download_connection_error(self):
213219 conntype = "ble" ,
214220 file = open (temp_path , "r" ),
215221 name = "MyHub" ,
222+ start = False ,
223+ wait = False ,
216224 )
217225
218226 stack .enter_context (
@@ -226,9 +234,9 @@ async def test_download_connection_error(self):
226234 )
227235
228236 # Run the command and verify it raises the error
229- download = Download ()
237+ run = Run ()
230238 with pytest .raises (RuntimeError , match = "Connection failed" ):
231- await download .run (args )
239+ await run .run (args )
232240
233241 # Verify disconnect was not called since connection failed
234242 mock_hub .disconnect .assert_not_called ()
0 commit comments