Skip to content

Commit 399ba43

Browse files
committed
Rename push to download.
1 parent 5314a99 commit 399ba43

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

pybricksdev/cli/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ def is_pybricks_usb(dev):
236236
await hub.disconnect()
237237

238238

239-
class Push(Tool):
239+
class Download(Tool):
240240
def add_parser(self, subparsers: argparse._SubParsersAction):
241241
parser = subparsers.add_parser(
242-
"push",
242+
"download",
243243
help="upload a Pybricks program without running it",
244244
)
245245
parser.tool = self
@@ -339,7 +339,7 @@ def is_pybricks_usb(dev):
339339
elif args.conntype == "ssh":
340340
await hub.download(script_path)
341341
else:
342-
raise RuntimeError("Unsupported hub type for push command")
342+
raise RuntimeError("Unsupported hub type for download command")
343343
finally:
344344
await hub.disconnect()
345345

@@ -567,7 +567,7 @@ def main():
567567
help="the tool to use",
568568
)
569569

570-
for tool in Compile(), Run(), Push(), Flash(), DFU(), OAD(), LWP3(), Udev():
570+
for tool in Compile(), Run(), Download(), Flash(), DFU(), OAD(), LWP3(), Udev():
571571
tool.add_parser(subparsers)
572572

573573
argcomplete.autocomplete(parser)

tests/test_cli.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import pytest
1010

11-
from pybricksdev.cli import Push, Tool
11+
from pybricksdev.cli import Download, Tool
1212

1313

1414
class TestTool:
@@ -20,23 +20,23 @@ def test_is_abstract(self):
2020
Tool()
2121

2222

23-
class TestPush:
24-
"""Tests for the Push command."""
23+
class TestDownload:
24+
"""Tests for the Download command."""
2525

2626
def test_add_parser(self):
2727
"""Test that the parser is set up correctly."""
2828
# Create a subparsers object
2929
parser = argparse.ArgumentParser()
3030
subparsers = parser.add_subparsers()
3131

32-
# Add the push command
33-
push = Push()
34-
push.add_parser(subparsers)
32+
# Add the download command
33+
download = Download()
34+
download.add_parser(subparsers)
3535

3636
# Verify the parser was created with correct arguments
37-
assert "push" in subparsers.choices
38-
parser = subparsers.choices["push"]
39-
assert parser.tool is push
37+
assert "download" in subparsers.choices
38+
parser = subparsers.choices["download"]
39+
assert parser.tool is download
4040

4141
# Test that required arguments are present
4242
mock_file = mock_open(read_data="print('test')")
@@ -59,8 +59,8 @@ def test_add_parser(self):
5959
parser.parse_args(["invalid", "test.py"])
6060

6161
@pytest.mark.asyncio
62-
async def test_push_ble(self):
63-
"""Test running the push command with BLE connection."""
62+
async def test_download_ble(self):
63+
"""Test running the download command with BLE connection."""
6464
# Create a mock hub
6565
mock_hub = AsyncMock()
6666
mock_hub._mpy_abi_version = 6
@@ -92,8 +92,8 @@ async def test_push_ble(self):
9292
"pybricksdev.compile.compile_multi_file", return_value=mock_mpy
9393
):
9494
# Run the command
95-
push = Push()
96-
await push.run(args)
95+
download = Download()
96+
await download.run(args)
9797

9898
# Verify the hub was created and used correctly
9999
mock_hub_class.assert_called_once_with("mock_device")
@@ -104,8 +104,8 @@ async def test_push_ble(self):
104104
os.unlink(temp_path)
105105

106106
@pytest.mark.asyncio
107-
async def test_push_usb(self):
108-
"""Test running the push command with USB connection."""
107+
async def test_download_usb(self):
108+
"""Test running the download command with USB connection."""
109109
# Create a mock hub
110110
mock_hub = AsyncMock()
111111
mock_hub._mpy_abi_version = 6
@@ -137,8 +137,8 @@ async def test_push_usb(self):
137137
"pybricksdev.compile.compile_multi_file", return_value=mock_mpy
138138
):
139139
# Run the command
140-
push = Push()
141-
await push.run(args)
140+
download = Download()
141+
await download.run(args)
142142

143143
# Verify the hub was created and used correctly
144144
mock_hub_class.assert_called_once_with("mock_device")
@@ -149,8 +149,8 @@ async def test_push_usb(self):
149149
os.unlink(temp_path)
150150

151151
@pytest.mark.asyncio
152-
async def test_push_ssh(self):
153-
"""Test running the push command with SSH connection."""
152+
async def test_download_ssh(self):
153+
"""Test running the download command with SSH connection."""
154154
# Create a mock hub
155155
mock_hub = AsyncMock()
156156
mock_hub.download = AsyncMock()
@@ -174,8 +174,8 @@ async def test_push_ssh(self):
174174
) as mock_hub_class:
175175
with patch("socket.gethostbyname", return_value="192.168.1.1"):
176176
# Run the command
177-
push = Push()
178-
await push.run(args)
177+
download = Download()
178+
await download.run(args)
179179

180180
# Verify the hub was created and used correctly
181181
mock_hub_class.assert_called_once_with("192.168.1.1")
@@ -186,7 +186,7 @@ async def test_push_ssh(self):
186186
os.unlink(temp_path)
187187

188188
@pytest.mark.asyncio
189-
async def test_push_ssh_no_name(self):
189+
async def test_download_ssh_no_name(self):
190190
"""Test that SSH connection requires a name."""
191191
# Create a temporary file
192192
with tempfile.NamedTemporaryFile(suffix=".py", mode="w+", delete=False) as temp:
@@ -202,15 +202,15 @@ async def test_push_ssh_no_name(self):
202202
)
203203

204204
# Run the command and verify it exits
205-
push = Push()
205+
download = Download()
206206
with pytest.raises(SystemExit, match="1"):
207-
await push.run(args)
207+
await download.run(args)
208208
finally:
209209
os.unlink(temp_path)
210210

211211
@pytest.mark.asyncio
212-
async def test_push_stdin(self):
213-
"""Test running the push command with stdin input."""
212+
async def test_download_stdin(self):
213+
"""Test running the download command with stdin input."""
214214
# Create a mock hub
215215
mock_hub = AsyncMock()
216216
mock_hub._mpy_abi_version = 6
@@ -245,8 +245,8 @@ async def test_push_stdin(self):
245245
"/tmp/test.py"
246246
)
247247
# Run the command
248-
push = Push()
249-
await push.run(args)
248+
download = Download()
249+
await download.run(args)
250250

251251
# Verify the hub was created and used correctly
252252
mock_hub_class.assert_called_once_with("mock_device")
@@ -255,7 +255,7 @@ async def test_push_stdin(self):
255255
mock_hub.disconnect.assert_called_once()
256256

257257
@pytest.mark.asyncio
258-
async def test_push_connection_error(self):
258+
async def test_download_connection_error(self):
259259
"""Test handling connection errors."""
260260
# Create a mock hub that raises an error during connect
261261
mock_hub = AsyncMock()
@@ -287,9 +287,9 @@ async def test_push_connection_error(self):
287287
"pybricksdev.compile.compile_multi_file", return_value=mock_mpy
288288
):
289289
# Run the command and verify it raises the error
290-
push = Push()
290+
download = Download()
291291
with pytest.raises(RuntimeError, match="Connection failed"):
292-
await push.run(args)
292+
await download.run(args)
293293

294294
# Verify disconnect was not called since connection failed
295295
mock_hub.disconnect.assert_not_called()

0 commit comments

Comments
 (0)