1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
import pytest
from briefcase.exceptions import BriefcaseCommandError, UnsupportedHostError
from briefcase.integrations.linuxdeploy import LinuxDeployLocalFilePlugin
from .utils import create_mock_appimage
@pytest.mark.parametrize("host_os", ["Windows", "wonky"])
def test_unsupported_os(mock_tools, host_os):
"""When host OS is not supported, an error is raised."""
mock_tools.host_os = host_os
with pytest.raises(
UnsupportedHostError,
match=f"{LinuxDeployLocalFilePlugin.name} is not supported on {host_os}",
):
LinuxDeployLocalFilePlugin.verify(mock_tools)
def test_verify(mock_tools, tmp_path):
"""Local file plugins are installed by copying."""
plugin_path = tmp_path / "path/to/linuxdeploy-plugin-custom.sh"
create_mock_appimage(plugin_path)
LinuxDeployLocalFilePlugin.verify(
mock_tools,
plugin_path=plugin_path,
bundle_path=tmp_path / "bundle",
)
# The plugin is copied into place
assert (tmp_path / "bundle/linuxdeploy-plugin-custom.sh").exists()
def test_bad_path(mock_tools, tmp_path):
"""If the plugin file path is invalid, an error is raised."""
plugin_path = tmp_path / "path/to/linuxdeploy-plugin-custom.sh"
with pytest.raises(
BriefcaseCommandError,
match=r"Could not locate linuxdeploy plugin ",
):
LinuxDeployLocalFilePlugin.verify(
mock_tools,
plugin_path=plugin_path,
bundle_path=tmp_path / "bundle",
)
def test_non_plugin(mock_tools, tmp_path):
"""If the plugin file path exists, but the filename doesn't match the pattern of a
linuxdeploy plugin, an error is raised."""
plugin_path = tmp_path / "path/to/not-a-plugin.exe"
create_mock_appimage(plugin_path)
with pytest.raises(
BriefcaseCommandError,
match=r"not-a-plugin.exe is not a linuxdeploy plugin",
):
LinuxDeployLocalFilePlugin.verify(
mock_tools,
plugin_path=plugin_path,
bundle_path=tmp_path / "bundle",
)
|