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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
import pytest
from briefcase.config import AppConfig
from .conftest import DummyCommand
@pytest.fixture
def first_app():
return AppConfig(
app_name="first",
bundle="com.example",
version="0.0.1",
description="The first simple app",
sources=["src/first"],
license={"file": "LICENSE"},
)
@pytest.fixture
def second_app():
return AppConfig(
app_name="second",
bundle="com.example",
version="0.0.2",
description="The second simple app",
sources=["src/second"],
license={"file": "LICENSE"},
)
@pytest.fixture
def base_command(tmp_path, first_app, second_app):
return DummyCommand(
base_path=tmp_path,
apps={
"first": first_app,
"second": second_app,
},
)
def test_finalize_all(base_command, first_app, second_app):
"A call to finalize verifies host, tools, and finalized all app configs"
base_command.finalize()
# The right sequence of things will be done
assert base_command.actions == [
# Host OS is verified
("verify-host",),
# Tools are verified
("verify-tools",),
# App config has been finalized
("finalize-app-config", "first"),
# App config has been finalized
("finalize-app-config", "second"),
]
# Apps are no longer in draft mode
assert not hasattr(first_app, "__draft__")
assert not hasattr(second_app, "__draft__")
def test_finalize_single(base_command, first_app, second_app):
"A call to finalize verifies host, tools, and finalized all app configs"
base_command.finalize(first_app)
# The right sequence of things will be done
assert base_command.actions == [
# Host OS is verified
("verify-host",),
# Tools are verified
("verify-tools",),
# App config has been finalized
("finalize-app-config", "first"),
]
# First app is no longer in draft mode; second is
assert not hasattr(first_app, "__draft__")
assert hasattr(second_app, "__draft__")
def test_finalize_all_repeat(base_command, first_app, second_app):
"Multiple calls to finalize verifies host & tools multiple times, but only once on config"
# Finalize apps twice. This is an approximation of what happens
# when a command chain is executed; create, update, build and run will
# all finalize; create will finalize the app configs, each command will
# have it's own tools verified.
base_command.finalize()
base_command.finalize()
# The right sequence of things will be done
assert base_command.actions == [
# Host OS is verified
("verify-host",),
# Tools are verified
("verify-tools",),
# App config has been finalized
("finalize-app-config", "first"),
# App config has been finalized
("finalize-app-config", "second"),
# Host OS is verified again
("verify-host",),
# Tools are verified again
("verify-tools",),
]
# Apps are no longer in draft mode
assert not hasattr(first_app, "__draft__")
assert not hasattr(second_app, "__draft__")
def test_finalize_single_repeat(base_command, first_app, second_app):
"Multiple calls to finalize verifies host & tools multiple times, but finalizes app config once"
# Finalize app twice. This is an approximation of what happens
# when a command chain is executed; create, update, build and run will
# all finalize; create will finalize the app config, each command will
# have it's own tools verified.
base_command.finalize(first_app)
base_command.finalize(first_app)
# The right sequence of things will be done
assert base_command.actions == [
# Host OS is verified
("verify-host",),
# Tools are verified
("verify-tools",),
# App config has been finalized
("finalize-app-config", "first"),
# Host OS is verified again
("verify-host",),
# Tools are verified again
("verify-tools",),
]
# First app is no longer in draft mode; second is
assert not hasattr(first_app, "__draft__")
assert hasattr(second_app, "__draft__")
|