コード例 #1
0
def test_bundle_good_package():
    with _clean_package_file(_PACKAGE_NAME_GLOB):
        returncode, stdout, stderr = common.exec_command(
            ['dcos', 'package', 'bundle', '--output-directory=/tmp',
             'tests/data/package/create-directory'])

        assert returncode == 0
        assert stdout == b''
        assert stderr.decode('utf-8').startswith(
            'Created DCOS Universe package ')

        with zipfile.ZipFile(
                'tests/data/package/cassandra.zip',
                'r') as expected:
            with zipfile.ZipFile(
                    glob.glob(_PACKAGE_NAME_GLOB)[0],
                    'r') as actual:

                for expected_file, actual_file in zip(
                    sorted(
                        expected.infolist(),
                        key=lambda x: x.filename),
                    sorted(
                        actual.infolist(),
                        key=lambda x: x.filename)):
                    assert expected_file.filename == actual_file.filename
                    assert expected_file.file_size == actual_file.file_size
コード例 #2
0
def test_bundle_fail_missing_output_directory():
    returncode, stdout, stderr = common.exec_command(
        ['dcos', 'package', 'bundle', '--output-directory=/temp',
         'tests/data/package/create-directory'])

    assert returncode == 1
    assert stdout == b''
    assert stderr.decode('utf-8').startswith(
        'No such file or directory: /temp/cassandra-0.2.0-1-')

    assert not glob.glob(_PACKAGE_NAME_GLOB)
コード例 #3
0
def test_bundle_fail_output_not_directory():
    with tempfile.NamedTemporaryFile() as temp_file:
        returncode, stdout, stderr = common.exec_command(
            ['dcos', 'package', 'bundle',
             '--output-directory={}'.format(temp_file.name),
             'tests/data/package/create-directory'])

        assert returncode == 1
        assert stdout == b''
        assert stderr.decode('utf-8').startswith(
            'Not a directory: {}/cassandra-0.2.0-1-'.format(temp_file.name))

    assert not glob.glob(_PACKAGE_NAME_GLOB)
コード例 #4
0
def test_bundle_fail_overwrite_existing_file():
    with _clean_package_file(_PACKAGE_NAME_GLOB):
        returncode, stdout, stderr = common.exec_command(
            ['dcos', 'package', 'bundle', '--output-directory=/tmp',
             'tests/data/package/create-directory'])

        assert returncode == 0
        assert stdout == b''
        assert stderr.decode('utf-8').startswith(
            'Created DCOS Universe package ')

        common.assert_command(
            ['dcos', 'package', 'bundle', '--output-directory=/tmp',
             'tests/data/package/create-directory'],
            returncode=1,
            stderr='Output file [{}] already exists\n'.format(
                glob.glob(_PACKAGE_NAME_GLOB)[0]).encode('utf-8'))