File: test_mixin.py

package info (click to toggle)
python-briefcase 0.3.22-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,296 kB
  • sloc: python: 59,405; makefile: 57
file content (79 lines) | stat: -rw-r--r-- 2,336 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from unittest.mock import MagicMock

import pytest

import briefcase.integrations.xcode
from briefcase.console import Console
from briefcase.exceptions import NoDistributionArtefact
from briefcase.platforms.iOS.xcode import iOSXcodeCreateCommand


@pytest.fixture
def create_command(tmp_path):
    return iOSXcodeCreateCommand(
        console=Console(),
        base_path=tmp_path / "base_path",
        data_path=tmp_path / "briefcase",
    )


def test_binary_path(create_command, first_app_config, tmp_path):
    binary_path = create_command.binary_path(first_app_config)

    assert binary_path == (
        tmp_path
        / "base_path"
        / "build"
        / "first-app"
        / "ios"
        / "xcode"
        / "build"
        / "Debug-iphonesimulator"
        / "First App.app"
    )


def test_distribution_path(create_command, first_app_config, tmp_path):
    with pytest.raises(
        NoDistributionArtefact,
        match=r"WARNING: No distributable artefact has been generated",
    ):
        create_command.distribution_path(first_app_config)


def test_verify(create_command, monkeypatch):
    """If you're on macOS, you can verify tools."""
    create_command.tools.host_os = "Darwin"

    mock_ensure_xcode_is_installed = MagicMock()
    monkeypatch.setattr(
        briefcase.integrations.xcode.Xcode,
        "ensure_xcode_is_installed",
        mock_ensure_xcode_is_installed,
    )
    mock_ensure_command_line_tools_are_installed = MagicMock()
    monkeypatch.setattr(
        briefcase.integrations.xcode.XcodeCliTools,
        "ensure_command_line_tools_are_installed",
        mock_ensure_command_line_tools_are_installed,
    )
    mock_confirm_xcode_license_accepted = MagicMock()
    monkeypatch.setattr(
        briefcase.integrations.xcode.XcodeCliTools,
        "confirm_xcode_license_accepted",
        mock_confirm_xcode_license_accepted,
    )

    create_command.verify_tools()

    assert create_command.tools.xcode_cli is not None
    mock_ensure_xcode_is_installed.assert_called_once_with(
        tools=create_command.tools,
        min_version=(13, 0, 0),
    )
    mock_ensure_command_line_tools_are_installed.assert_called_once_with(
        tools=create_command.tools
    )
    mock_confirm_xcode_license_accepted.assert_called_once_with(
        tools=create_command.tools
    )