Пример #1
0
def test_describe_options():
    stdout = file_json(
        'tests/data/package/json/test_describe_app_options.json')
    stdout = json.loads(stdout.decode('utf-8'))
    expected_labels = stdout.pop("labels", None)

    with util.temptext(b'{"name": "hallo", "port": 80}') as options:
        returncode, stdout_, stderr = exec_command(
            ['dcos', 'package', 'describe', '--app', '--options',
             options[1], 'helloworld'])

    stdout_ = json.loads(stdout_.decode('utf-8'))
    actual_labels = stdout_.pop("labels", None)

    for label, value in expected_labels.items():
        if label in ["DCOS_PACKAGE_METADATA", "DCOS_PACKAGE_OPTIONS"]:
            # We covert the metadata into a dictionary
            # so that failures in equality are more descriptive
            assert base64_to_dict(value) == \
                base64_to_dict(actual_labels.get(label))
        else:
            assert value == actual_labels.get(label)

    assert stdout == stdout_
    assert stderr == b''
    assert returncode == 0
Пример #2
0
def test_describe_render():
    stdout = file_json(
        'tests/data/package/json/test_describe_helloworld_app_render.json')
    stdout = json.loads(stdout.decode('utf-8'))
    expected_labels = stdout.pop("labels", None)

    returncode, stdout_, stderr = exec_command(
        ['dcos', 'package', 'describe', 'helloworld', '--app', '--render'])

    stdout_ = json.loads(stdout_.decode('utf-8'))
    actual_labels = stdout_.pop("labels", None)

    for label, value in expected_labels.items():
        if label == "DCOS_PACKAGE_METADATA":
            # We covert the metadata into a dictionary
            # so that failures in equality are more descriptive
            assert base64_to_dict(value) == \
                base64_to_dict(actual_labels.get(label))
        else:
            assert value == actual_labels.get(label)

    assert stdout == stdout_
    assert stderr == b''
    assert returncode == 0
Пример #3
0
def test_package_metadata():
    _install_helloworld()

    # test marathon labels
    expected_metadata = {
        'maintainer': '*****@*****.**',
        'framework': False,
        'name': 'helloworld',
        'version': '0.1.0',
        'packagingVersion': '3.0',
        'preInstallNotes': 'A sample pre-installation message',
        'selected': False,
        'website': 'https://github.com/mesosphere/dcos-helloworld',
        'description': 'Example DCOS application package',
        'tags': ['mesosphere', 'example', 'subcommand'],
        'postInstallNotes': 'A sample post-installation message'
    }

    expected_source = bytes(
        UNIVERSE_TEST_REPOS['helloworld-universe'],
        'utf-8'
    )

    expected_labels = {
        'DCOS_PACKAGE_NAME': b'helloworld',
        'DCOS_PACKAGE_VERSION': b'0.1.0',
        'DCOS_PACKAGE_SOURCE': expected_source,
    }

    app_labels = _get_app_labels('helloworld')
    for label, value in expected_labels.items():
        assert value == six.b(app_labels.get(label))

    assert expected_metadata == base64_to_dict(six.b(
        app_labels.get('DCOS_PACKAGE_METADATA')))

    # test local package.json
    package = file_json(
        'tests/data/package/json/test_package_metadata.json')
    package = json.loads(package.decode("UTF-8"))

    helloworld_subcommand = subcommand.InstalledSubcommand("helloworld")

    # test local package.json
    assert helloworld_subcommand.package_json() == package

    # uninstall helloworld
    _uninstall_helloworld()