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
|
import pytest
from briefcase.exceptions import BriefcaseCommandError
def test_single_source(base_command, my_app):
"""If an app provides a single source location and it matches, it is selected as the
dist-info location."""
my_app.sources = ["src/my_app"]
assert base_command.app_module_path(my_app) == base_command.base_path / "src/my_app"
def test_no_prefix(base_command, my_app):
"""If an app provides a source location without a prefix and it matches, it is
selected as the dist-info location."""
my_app.sources = ["my_app"]
assert base_command.app_module_path(my_app) == base_command.base_path / "my_app"
def test_long_prefix(base_command, my_app):
"""If an app provides a source location with a long prefix and it matches, it is
selected as the dist-info location."""
my_app.sources = ["path/to/src/my_app"]
assert (
base_command.app_module_path(my_app)
== base_command.base_path / "path/to/src/my_app"
)
def test_matching_source(base_command, my_app):
"""If an app provides a single matching source location, it is selected as the dist-
info location."""
my_app.sources = ["src/other", "src/my_app", "src/extra"]
assert base_command.app_module_path(my_app) == base_command.base_path / "src/my_app"
def test_multiple_match(base_command, my_app):
"""If an app provides multiple matching source location, an error is raised."""
my_app.sources = ["src/my_app", "extra/my_app"]
with pytest.raises(
BriefcaseCommandError,
match=r"Multiple paths in sources found for application 'my-app'",
):
base_command.app_module_path(my_app)
def test_hyphen_source(base_command, my_app):
"""If an app provides a single source location with a hyphen, an error is raised."""
# The source directory must be a valid module, so hyphens aren't legal.
my_app.sources = ["src/my-app"]
with pytest.raises(
BriefcaseCommandError,
match=r"Unable to find code for application 'my-app'",
):
base_command.app_module_path(my_app)
def test_no_match(base_command, my_app):
"""If an app provides a multiple locations, none of which match, an error is
raised."""
my_app.sources = ["src/pork", "src/spam"]
with pytest.raises(
BriefcaseCommandError,
match=r"Unable to find code for application 'my-app'",
):
base_command.app_module_path(my_app)
def test_no_source(base_command, my_app):
"""If an app provides no source locations, an error is raised."""
my_app.sources = []
with pytest.raises(
BriefcaseCommandError,
match=r"Unable to find code for application 'my-app'",
):
base_command.app_module_path(my_app)
|