Update unit tests for testing linux behavior

This commit is contained in:
Microchip
2026-09-26 14:45:46 -04:00
parent 919145569a
commit bf938b838e
3 changed files with 67 additions and 5 deletions
+60 -1
View File
@@ -45,7 +45,6 @@ def test_ensure_aria2c_returns_windows_path(monkeypatch):
assert torrent.ensure_aria2c() == expected
def test_ensure_aria2c_installs_when_not_found(monkeypatch):
monkeypatch.setattr(
torrent,
@@ -53,6 +52,12 @@ def test_ensure_aria2c_installs_when_not_found(monkeypatch):
Mock(return_value=None),
)
monkeypatch.setattr(
torrent.sys,
"platform",
"win32",
)
installer = Mock(
return_value="/fake/aria2c.exe"
)
@@ -73,6 +78,60 @@ def test_ensure_aria2c_installs_when_not_found(monkeypatch):
log_fn=torrent.log,
)
def test_ensure_aria2c_linux_returns_installed_binary(monkeypatch):
monkeypatch.setattr(
torrent.sys,
"platform",
"linux",
)
monkeypatch.setattr(
torrent,
"find_aria2c",
Mock(return_value="/usr/bin/aria2c"),
)
installer = Mock()
monkeypatch.setattr(
torrent,
"install_aria2c_windows",
installer,
)
result = torrent.ensure_aria2c()
assert result == "/usr/bin/aria2c"
installer.assert_not_called()
def test_ensure_aria2c_linux_raises_when_not_installed(monkeypatch):
monkeypatch.setattr(
torrent.sys,
"platform",
"linux",
)
monkeypatch.setattr(
torrent,
"find_aria2c",
Mock(return_value=None),
)
installer = Mock()
monkeypatch.setattr(
torrent,
"install_aria2c_windows",
installer,
)
with pytest.raises(
RuntimeError,
match="aria2c required but not installed",
):
torrent.ensure_aria2c()
installer.assert_not_called()
def test_ensure_aria2c_passes_custom_logger(monkeypatch):
monkeypatch.setattr(