| 1 |
import pytest |
| 2 |
|
| 3 |
from briefcase.exceptions import UnsupportedHostError |
| 4 |
from briefcase.platforms.windows.visualstudio import WindowsVisualStudioCreateCommand |
| 5 |
|
| 6 |
|
| 7 |
@pytest.fixture |
| 8 |
def create_command(dummy_console, tmp_path): |
| 9 |
return WindowsVisualStudioCreateCommand( |
| 10 |
console=dummy_console, |
| 11 |
base_path=tmp_path / "base_path", |
| 12 |
data_path=tmp_path / "briefcase", |
| 13 |
) |
| 14 |
|
| 15 |
|
| 16 |
@pytest.mark.parametrize("host_os", ["Darwin", "Linux", "WeirdOS"]) |
| 17 |
def test_unsupported_host_os(create_command, host_os): |
| 18 |
"""Error raised for an unsupported OS.""" |
| 19 |
create_command.tools.host_os = host_os |
| 20 |
|
| 21 |
with pytest.raises( |
| 22 |
UnsupportedHostError, |
| 23 |
match=r"Windows applications can only be built on Windows\.", |
| 24 |
): |
| 25 |
create_command() |
| 26 |
|
| 27 |
|
| 28 |
def test_binary_path(create_command, first_app_config, tmp_path): |
| 29 |
binary_path = create_command.binary_path(first_app_config) |
| 30 |
|
| 31 |
assert ( |
| 32 |
binary_path |
| 33 |
== tmp_path |
| 34 |
/ "base_path" |
| 35 |
/ "build" |
| 36 |
/ "first-app" |
| 37 |
/ "windows" |
| 38 |
/ "visualstudio" |
| 39 |
/ "x64" |
| 40 |
/ "Release" |
| 41 |
/ "First App.exe" |
| 42 |
) |
| 43 |
|
| 44 |
|
| 45 |
def test_project_path(create_command, first_app_config, tmp_path): |
| 46 |
"""The project path is the Visual Studio solution.""" |
| 47 |
project_path = create_command.project_path(first_app_config) |
| 48 |
|
| 49 |
expected_path = ( |
| 50 |
tmp_path |
| 51 |
/ "base_path" |
| 52 |
/ "build" |
| 53 |
/ "first-app" |
| 54 |
/ "windows" |
| 55 |
/ "visualstudio" |
| 56 |
/ "First App.sln" |
| 57 |
) |
| 58 |
assert expected_path == project_path |
| 59 |
|
| 60 |
|
| 61 |
def test_distribution_path(create_command, first_app_config, tmp_path): |
| 62 |
distribution_path = create_command.distribution_path(first_app_config) |
| 63 |
|
| 64 |
assert distribution_path == tmp_path / "base_path/dist/First App-0.0.1.msi" |