コード例 #1
0
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'
    assert config.document_types == {}

    # There is no icon or splash of any kind
    assert config.icon is None
    assert config.splash is None

    assert repr(config) == "<org.beeware.myapp v1.2.3 AppConfig>"
コード例 #2
0
def test_doctype_icon_target(create_command, tmp_path):
    "If the template defines document types, their icons will be installed"
    myapp = AppConfig(app_name='my-app',
                      formal_name='My App',
                      bundle='com.example',
                      version='1.2.3',
                      description='This is a simple app',
                      sources=['src/my_app'],
                      document_type={
                          'mydoc': {
                              'icon': 'images/mydoc-icon'
                          },
                          'other': {
                              'icon': 'images/other-icon',
                          }
                      })

    # Prime the path index with 2 document types;
    # * mydoc, which has a single static image; and
    # * other, which has multiple size targets.
    create_command._path_index = {
        myapp: {
            'document_type_icon': {
                'mydoc': 'path/to/mydoc-icon.png',
                'other': {
                    '10': 'path/to/other-icon-10.png',
                    '20': 'path/to/other-icon-20.png',
                }
            }
        }
    }

    install_image = mock.MagicMock()
    create_command.install_image = install_image

    # Install app resources
    create_command.install_app_resources(myapp)

    # 2 calls to install doctype icon images will be made
    install_image.assert_has_calls([
        mock.call(
            'icon for .mydoc documents',
            source='images/mydoc-icon',
            variant=None,
            size=None,
            target=tmp_path / 'tester/my-app.bundle/path/to/mydoc-icon.png'),
        mock.call('icon for .other documents',
                  source='images/other-icon',
                  variant=None,
                  size='10',
                  target=tmp_path /
                  'tester/my-app.bundle/path/to/other-icon-10.png'),
        mock.call('icon for .other documents',
                  source='images/other-icon',
                  variant=None,
                  size='20',
                  target=tmp_path /
                  'tester/my-app.bundle/path/to/other-icon-20.png'),
    ],
                                   any_order=True)
コード例 #3
0
ファイル: test_AppConfig.py プロジェクト: danyeaw/briefcase
def test_minimal_AppConfig():
    """A simple config can be defined."""
    config = AppConfig(
        app_name="myapp",
        version="1.2.3",
        bundle="org.beeware",
        description="A simple app",
        sources=["src/myapp", "somewhere/else/interesting"],
    )

    # The basic properties have been set.
    assert config.app_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"
    assert config.document_types == {}

    # There is no icon or splash of any kind
    assert config.icon is None
    assert config.splash is None

    # The PYTHONPATH is derived correctly
    assert config.PYTHONPATH == ["src", "somewhere/else"]

    # The object has a meaningful REPL
    assert repr(config) == "<org.beeware.myapp v1.2.3 AppConfig>"
コード例 #4
0
def second_app_config():
    return AppConfig(
        app_name='second',
        bundle='com.example',
        version='0.0.2',
        description='The second simple app',
        sources=['src/second'],
    )
コード例 #5
0
def test_package_name(bundle, package_name):
    config = AppConfig(app_name="myapp",
                       version="1.2.3",
                       bundle=bundle,
                       description="A simple app",
                       sources=['src/myapp'])

    assert config.package_name == package_name
コード例 #6
0
def first_app_config():
    return AppConfig(
        app_name='first',
        bundle='com.example',
        version='0.0.1',
        description='The first simple app',
        sources=['src/first'],
    )
コード例 #7
0
def test_invalid_app_name(name):
    with pytest.raises(BriefcaseConfigError,
                       match=r"is not a valid app name\."):
        AppConfig(app_name=name,
                  version="1.2.3",
                  bundle="org.beeware",
                  description="A simple app",
                  sources=['src/invalid'])
コード例 #8
0
ファイル: conftest.py プロジェクト: danyeaw/briefcase
def second_app_config():
    return AppConfig(
        app_name="second",
        bundle="com.example",
        version="0.0.2",
        description="The second simple app",
        sources=["src/second"],
    )
コード例 #9
0
def test_duplicated_source(sources):
    with pytest.raises(BriefcaseConfigError,
                       match=r"contains duplicated package names\."):
        AppConfig(app_name='dupe',
                  version="1.2.3",
                  bundle="org.beeware",
                  description="A simple app",
                  sources=sources)
コード例 #10
0
def test_no_source_for_app():
    with pytest.raises(BriefcaseConfigError,
                       match=r" does not include a package named 'my_app'\."):
        AppConfig(app_name='my-app',
                  version="1.2.3",
                  bundle="org.beeware",
                  description="A simple app",
                  sources=['src/something', 'src/other'])
コード例 #11
0
def test_module_name(name, module_name):
    config = AppConfig(app_name=name,
                       version="1.2.3",
                       bundle="org.beeware",
                       description="A simple app",
                       sources=['src/' + module_name])

    assert config.module_name == module_name
コード例 #12
0
def test_invalid_app_version():
    with pytest.raises(BriefcaseConfigError,
                       match=r"Version number for myapp.*is not valid\."):
        AppConfig(app_name="myapp",
                  version="foobar",
                  bundle="org.beeware",
                  description="A simple app",
                  sources=['src/invalid'])
コード例 #13
0
ファイル: conftest.py プロジェクト: danyeaw/briefcase
def first_app_config():
    return AppConfig(
        app_name="first",
        bundle="com.example",
        version="0.0.1",
        description="The first simple app",
        sources=["src/first"],
    )
コード例 #14
0
def test_valid_app_name(name):
    try:
        AppConfig(app_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))
コード例 #15
0
def my_app():
    return AppConfig(
        app_name='my-app',
        formal_name='My App',
        bundle='com.example',
        version='1.2.3',
        description='This is a simple app',
        sources=['src/my_app'],
    )
コード例 #16
0
def my_app():
    return AppConfig(
        app_name="my-app",
        formal_name="My App",
        bundle="com.example",
        version="1.2.3",
        description="This is a simple app",
        sources=["src/my_app"],
    )
コード例 #17
0
def test_valid_app_version():
    try:
        AppConfig(app_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')
コード例 #18
0
def pytest_cmdline_main(config):
    "Parse the command line, adding the sys.path entries needed to support the app"
    app_name = config.getoption("app")
    platform = config.getoption("platform")

    # Load the platform module and determine the default output format.
    platforms = get_platforms()
    platform_module = platforms[platform]

    # Determine the output format to target
    try:
        output_format = config.getoption("output_format")
    except ValueError:
        output_format = platform_module.DEFAULT_OUTPUT_FORMAT

    # Load the application config from the pyproject.toml
    # in the pytest rootdir
    _, app_configs = parse_config(config.rootdir / 'pyproject.toml',
                                  platform=platform,
                                  output_format=output_format)

    # If no app name has been provided, check to see if there is
    # a single app in the project. If there is, use it. Otherwise,
    # raise an error.
    # If an app name has been provided, load that app config.
    if app_name == '*':
        if len(app_configs) == 1:
            app = AppConfig(**list(app_configs.values())[0])
        else:
            raise BriefcasePytestConfigError(
                'More than one app in the porject. Specify an app name with --app'
            )
    else:
        try:
            app = AppConfig(**app_configs[app_name])
        except KeyError:
            raise BriefcasePytestConfigError(
                "'{app_name}' is not an app name in this project".format(
                    app_name=app_name))

    # Process the `sources` list for the app, adding to the pythonpath.
    # This matches the PYTHONPATH configuration done by `briefcase dev`
    for path in app.PYTHONPATH:
        sys.path.insert(0, str(config.rootdir / path))
コード例 #19
0
ファイル: conftest.py プロジェクト: danyeaw/briefcase
def first_app_config():
    return AppConfig(
        app_name="first-app",
        project_name="First Project",
        formal_name="First App",
        bundle="com.example",
        version="0.0.1",
        description="The first simple app",
        sources=["src/first_app"],
    )
コード例 #20
0
ファイル: conftest.py プロジェクト: tmontes/briefcase
def first_app_config():
    return AppConfig(
        app_name='first-app',
        project_name='First Project',
        formal_name='First App',
        bundle='com.example',
        version='0.0.1',
        description='The first simple app',
        sources=['src/first_app'],
    )
コード例 #21
0
ファイル: test_AppConfig.py プロジェクト: danyeaw/briefcase
def test_invalid_bundle_identifier(bundle):
    with pytest.raises(BriefcaseConfigError,
                       match=r"is not a valid bundle identifier\."):
        AppConfig(
            app_name="myapp",
            version="1.2.3",
            bundle=bundle,
            description="A simple app",
            sources=["src/invalid"],
        )
コード例 #22
0
ファイル: test_AppConfig.py プロジェクト: danyeaw/briefcase
def test_valid_app_name(name):
    try:
        AppConfig(
            app_name=name,
            version="1.2.3",
            bundle="org.beeware",
            description="A simple app",
            sources=["src/" + name.replace("-", "_")],
        )
    except BriefcaseConfigError:
        pytest.fail(f"{name} should be valid")
コード例 #23
0
ファイル: test_AppConfig.py プロジェクト: danyeaw/briefcase
def test_valid_bundle(bundle):
    try:
        AppConfig(
            app_name="myapp",
            version="1.2.3",
            bundle=bundle,
            description="A simple app",
            sources=["src/myapp"],
        )
    except BriefcaseConfigError:
        pytest.fail(f"{bundle} should be valid")
コード例 #24
0
def update_command(tmp_path):
    return DummyUpdateCommand(base_path=tmp_path,
                              apps={
                                  'first':
                                  AppConfig(
                                      app_name='first',
                                      bundle='com.example',
                                      version='0.0.1',
                                      description='The first simple app',
                                      sources=['src/first'],
                                  ),
                                  'second':
                                  AppConfig(
                                      app_name='second',
                                      bundle='com.example',
                                      version='0.0.2',
                                      description='The second simple app',
                                      sources=['src/second'],
                                  ),
                              })
コード例 #25
0
def tracking_create_command(tmp_path, mock_git):
    return TrackingCreateCommand(git=mock_git,
                                 base_path=tmp_path,
                                 apps={
                                     'first':
                                     AppConfig(
                                         app_name='first',
                                         bundle='com.example',
                                         version='0.0.1',
                                         description='The first simple app',
                                         sources=['src/first'],
                                     ),
                                     'second':
                                     AppConfig(
                                         app_name='second',
                                         bundle='com.example',
                                         version='0.0.2',
                                         description='The second simple app',
                                         sources=['src/second'],
                                     ),
                                 })
コード例 #26
0
ファイル: conftest.py プロジェクト: danyeaw/briefcase
def myapp():
    return AppConfig(
        app_name="my-app",
        formal_name="My App",
        bundle="com.example",
        version="1.2.3",
        description="This is a simple app",
        sources=["src/my_app"],
        url="https://example.com",
        author="First Last",
        author_email="*****@*****.**",
    )
コード例 #27
0
ファイル: conftest.py プロジェクト: danyeaw/briefcase
def update_command(tmp_path):
    return DummyUpdateCommand(
        base_path=tmp_path,
        apps={
            "first":
            AppConfig(
                app_name="first",
                bundle="com.example",
                version="0.0.1",
                description="The first simple app",
                sources=["src/first"],
            ),
            "second":
            AppConfig(
                app_name="second",
                bundle="com.example",
                version="0.0.2",
                description="The second simple app",
                sources=["src/second"],
            ),
        },
    )
コード例 #28
0
ファイル: conftest.py プロジェクト: xmonader/briefcase
def first_app_uninstalled(tmp_path):
    # Make sure the source code exists
    (tmp_path / "src" / "first").mkdir(parents=True, exist_ok=True)
    with (tmp_path / "src" / "first" / "__init__.py").open("w") as f:
        f.write('print("Hello world")')

    return AppConfig(
        app_name="first",
        bundle="com.example",
        version="0.0.1",
        description="The first simple app",
        sources=["src/first"],
    )
コード例 #29
0
def first_app_uninstalled(tmp_path):
    # Make sure the source code exists
    (tmp_path / 'src' / 'first').mkdir(parents=True, exist_ok=True)
    with (tmp_path / 'src' / 'first' / '__init__.py').open('w') as f:
        f.write('print("Hello world")')

    return AppConfig(
        name='first',
        bundle='com.example',
        version='0.0.1',
        description='The first simple app',
        sources=['src/first'],
    )
コード例 #30
0
ファイル: conftest.py プロジェクト: danyeaw/briefcase
def tracking_create_command(tmp_path, mock_git):
    return TrackingCreateCommand(
        git=mock_git,
        base_path=tmp_path,
        apps={
            "first":
            AppConfig(
                app_name="first",
                bundle="com.example",
                version="0.0.1",
                description="The first simple app",
                sources=["src/first"],
            ),
            "second":
            AppConfig(
                app_name="second",
                bundle="com.example",
                version="0.0.2",
                description="The second simple app",
                sources=["src/second"],
            ),
        },
    )