| 1 |
import os |
| 2 |
import sys |
| 3 |
from unittest.mock import MagicMock |
| 4 |
|
| 5 |
import pytest |
| 6 |
|
| 7 |
from briefcase.integrations.subprocess import Subprocess |
| 8 |
from briefcase.platforms.windows.app import WindowsAppOpenCommand |
| 9 |
|
| 10 |
|
| 11 |
@pytest.fixture |
| 12 |
def open_command(dummy_console, tmp_path, first_app_config): |
| 13 |
command = WindowsAppOpenCommand( |
| 14 |
console=dummy_console, |
| 15 |
base_path=tmp_path / "base_path", |
| 16 |
data_path=tmp_path / "briefcase", |
| 17 |
) |
| 18 |
command.tools.os = MagicMock(spec_set=os) |
| 19 |
command.tools.subprocess = MagicMock(spec_set=Subprocess) |
| 20 |
return command |
| 21 |
|
| 22 |
|
| 23 |
@pytest.mark.skipif(sys.platform != "win32", reason="Windows specific test") |
| 24 |
def test_open_windows(open_command, first_app_config, tmp_path): |
| 25 |
"""On Windows, open invokes `startfile` on the project folder.""" |
| 26 |
# Create the project folder to mock a created project. |
| 27 |
open_command.project_path(first_app_config).mkdir(parents=True) |
| 28 |
|
| 29 |
open_command(first_app_config) |
| 30 |
|
| 31 |
open_command.tools.os.startfile.assert_called_once_with( |
| 32 |
tmp_path / "base_path/build/first-app/windows/app" |
| 33 |
) |