Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,12 +1081,6 @@ def setSimpleConfig(modem_preset):
interface.getNode(args.dest, **getNode_kwargs).showInfo()
closeNow = True
print("")
pypi_version = meshtastic.util.check_if_newer_version()
if pypi_version:
print(
f"*** A newer version v{pypi_version} is available!"
' Consider running "pip install --upgrade meshtastic" ***\n'
)
else:
print("Showing info of remote node is not supported.")
print(
Expand Down
28 changes: 28 additions & 0 deletions meshtastic/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,34 @@ def mock_showInfo():
mo.assert_called()


@pytest.mark.unit
@pytest.mark.usefixtures("reset_mt_config")
@pytest.mark.parametrize("connection_args,interface_class", [
([], "meshtastic.serial_interface.SerialInterface"),
(["--host", "meshtastic.local"], "meshtastic.tcp_interface.TCPInterface"),
])
def test_main_info_without_internet(connection_args, interface_class, monkeypatch, capsys):
"""Local radio information must not make an Internet request."""
monkeypatch.setattr(sys, "argv", ["", "--info", *connection_args])
iface = MagicMock()
iface.showInfo.side_effect = lambda: print("Radio information")
iface.getNode.return_value.showInfo.side_effect = lambda: print("Node configuration")

with patch(interface_class, return_value=iface), patch(
"meshtastic.util.requests.get"
) as request:
main()

request.assert_not_called()
iface.showInfo.assert_called_once_with()
iface.getNode.return_value.showInfo.assert_called_once_with()
iface.close.assert_called()
out, err = capsys.readouterr()
assert "Radio information" in out
assert "Node configuration" in out
assert err == ""


@pytest.mark.unit
@pytest.mark.usefixtures("reset_mt_config")
@patch("os.getlogin")
Expand Down