File: test_properties.py

package info (click to toggle)
python-briefcase 0.3.25-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,596 kB
  • sloc: python: 62,519; makefile: 60
file content (122 lines) | stat: -rw-r--r-- 4,667 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
from pathlib import Path

from .conftest import DummyCommand


def test_briefcase_required_python_version(base_command):
    assert base_command.briefcase_required_python_version == (3, 10)


def test_bundle_path(base_command, my_app, tmp_path):
    bundle_path = base_command.bundle_path(my_app)

    assert bundle_path == tmp_path / "base_path/build/my-app/tester/dummy"


def test_package_path(base_command, my_app, tmp_path):
    package_path = base_command.package_path(my_app)
    bundle_package_path = base_command.bundle_package_path(my_app)

    assert package_path == tmp_path / "base_path/build/my-app/tester/dummy/src/package"
    assert (
        bundle_package_path
        == tmp_path / "base_path/build/my-app/tester/dummy/src/package"
    )


def test_external_package_path(base_command, my_app, tmp_path):
    my_app.external_package_path = "path/to/package"

    package_path = base_command.package_path(my_app)
    bundle_package_path = base_command.bundle_package_path(my_app)

    assert package_path == (Path.cwd() / "path/to/package")
    assert (
        bundle_package_path
        == tmp_path / "base_path/build/my-app/tester/dummy/src/package"
    )


def test_package_executable_path(base_command, my_app, tmp_path):
    package_executable_path = base_command.package_executable_path(my_app)
    bundle_package_executable_path = base_command.bundle_package_executable_path(my_app)

    assert package_executable_path == "internal/my-app.exe"
    assert bundle_package_executable_path == "internal/my-app.exe"


def test_external_package_executable_path(base_command, my_app, tmp_path):
    my_app.external_package_executable_path = "alternate/the_app.exe"

    package_executable_path = base_command.package_executable_path(my_app)
    bundle_package_executable_path = base_command.bundle_package_executable_path(my_app)

    assert package_executable_path == "alternate/the_app.exe"
    assert bundle_package_executable_path == "internal/my-app.exe"


def test_create_command(base_command):
    # Check for a property of the created command class.
    assert base_command.create_command.description == "Test Create"


def test_update_command(base_command):
    # Check for a property of the created command class.
    assert base_command.update_command.description == "Test Update"


def test_build_command(base_command):
    # Check for a property of the created command class.
    assert base_command.build_command.description == "Test Build"


def test_run_command(base_command):
    # Check for a property of the created command class.
    assert base_command.run_command.description == "Test Run"


def test_package_command(base_command):
    # Check for a property of the created command class.
    assert base_command.package_command.description == "Test Package"


def test_publish_command(base_command):
    # Check for a property of the created command class.
    assert base_command.publish_command.description == "Test Publish"


def test_command_state_transferred(dummy_console, tmp_path):
    """Command state is transferred to created subcommands."""
    command = DummyCommand(console=dummy_console, base_path=tmp_path)
    command.tools.console.input_enabled = False

    # Check the enabled state of subcommands
    assert not command.create_command.console.input_enabled
    assert command.create_command.console is command.tools.console
    assert command.create_command.tools is command.tools
    assert command.create_command.is_clone is True

    assert not command.update_command.console.input_enabled
    assert command.update_command.console is command.tools.console
    assert command.update_command.tools is command.tools
    assert command.update_command.is_clone is True

    assert not command.build_command.console.input_enabled
    assert command.build_command.console is command.tools.console
    assert command.build_command.tools is command.tools
    assert command.build_command.is_clone is True

    assert not command.run_command.console.input_enabled
    assert command.run_command.console is command.tools.console
    assert command.run_command.tools is command.tools
    assert command.run_command.is_clone is True

    assert not command.package_command.console.input_enabled
    assert command.package_command.console is command.tools.console
    assert command.package_command.tools is command.tools
    assert command.package_command.is_clone is True

    assert not command.publish_command.console.input_enabled
    assert command.publish_command.console is command.tools.console
    assert command.publish_command.tools is command.tools
    assert command.publish_command.is_clone is True