Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_module_name(name, module_name):
config = AppConfig(
name=name,
version="1.2.3",
bundle="org.beeware",
description="A simple app",
sources=['src/' + module_name]
)
assert config.module_name == module_name
def test_valid_app_version():
try:
AppConfig(
name="myapp",
version="1.2.3",
bundle="org.beeware",
description="A simple app",
sources=['src/myapp']
)
except BriefcaseConfigError:
pytest.fail('1.2.3 should be a valid version number')
def test_minimal_AppConfig():
"A simple config can be defined"
config = AppConfig(
name="myapp",
version="1.2.3",
bundle="org.beeware",
description="A simple app",
sources=['src/myapp'],
)
# The basic properties have been set.
assert config.name == "myapp"
assert config.version == '1.2.3'
assert config.bundle == 'org.beeware'
assert config.description == 'A simple app'
assert config.requires is None
# Derived properties have been set.
assert config.formal_name == 'myapp'
def test_no_source_for_app():
with pytest.raises(BriefcaseConfigError, match=r" does not include a package named 'my_app'\."):
AppConfig(
name='my-app',
version="1.2.3",
bundle="org.beeware",
description="A simple app",
sources=['src/something', 'src/other']
)
def test_extra_attrs():
"A config can contain attributes in addition to those required"
config = AppConfig(
name="myapp",
formal_name="My App",
version="1.2.3",
bundle="org.beeware",
description="A simple app",
template='/path/to/template',
sources=['src/myapp'],
requires=['first', 'second', 'third'],
document_type={
'document': {
'extension': 'doc',
'description': 'A document',
}
},
first="value 1",
second=42,
def test_no_resources(create_command):
"If the template defines no extra targets, none are installed"
myapp = AppConfig(
name='my-app',
formal_name='My App',
bundle='com.example',
version='1.2.3',
description='This is a simple app',
sources=['src/my_app'],
)
# Prime the path index with no targets
create_command._path_index = {myapp: {}}
install_image = mock.MagicMock()
create_command.install_image = install_image
# Install app resources
create_command.install_app_resources(myapp)
def test_icon_target(create_command, tmp_path):
"If the template defines an icon target, it will be installed"
myapp = AppConfig(
name='my-app',
formal_name='My App',
bundle='com.example',
version='1.2.3',
description='This is a simple app',
sources=['src/my_app'],
icon='images/icon'
)
# Prime the path index with 2 icon targets
create_command._path_index = {
myapp: {
'icon': {
'10': 'path/to/icon-10.png',
'20': 'path/to/icon-20.png',
}
def test_valid_app_name(name):
try:
AppConfig(
name=name,
version="1.2.3",
bundle="org.beeware",
description="A simple app",
sources=['src/' + name.replace('-', '_')]
)
except BriefcaseConfigError:
pytest.fail('{name} should be valid'.format(name=name))
def test_invalid_app_name(name):
with pytest.raises(BriefcaseConfigError, match=r"is not a valid app name\."):
AppConfig(
name=name,
version="1.2.3",
bundle="org.beeware",
description="A simple app",
sources=['src/invalid']
)
def test_splash_target(create_command, tmp_path):
"If the template defines an splash target, it will be installed"
myapp = AppConfig(
name='my-app',
formal_name='My App',
bundle='com.example',
version='1.2.3',
description='This is a simple app',
sources=['src/my_app'],
splash='images/splash'
)
# Prime the path index with 2 splash targets
create_command._path_index = {
myapp: {
'splash': {
'10x20': 'path/to/splash-10x20.png',
'20x30': 'path/to/splash-20x30.png',
}