Пример #1
0
def test_dist_uses_script_path_when_no_path_is_given(tmpdir):
    script = tmpdir.join('dist.py')
    script.write_text(
        u'''#!/usr/bin/env python

from mkp import dist


dist({
    'author': 'John Doe',
    'name': 'foo',
    'version': '42',
})
''', 'utf-8')
    script.chmod(0o700)
    tmpdir.join('agents', 'special', 'agent_test').write_binary(b'hello',
                                                                ensure=True)
    tmpdir.join('checks', 'foo').write_binary(b'Check Me!', ensure=True)

    script.sysexec()

    assert tmpdir.join('dist', 'foo-42.mkp').exists()
    package = mkp.load_file(str(tmpdir.join('dist', 'foo-42.mkp')))
    assert package.info['author'] == 'John Doe'
    assert package.info['name'] == 'foo'
    assert package.info['files']['agents'] == ['special/agent_test']
    assert package.info['files']['checks'] == ['foo']
    assert package.info['version'] == '42'
    assert package.info['version.packaged'] == 'python-mkp'
    assert package.info['num_files'] == 2
Пример #2
0
def test_load_file(original_mkp_file, tmpdir):
    tmpdir.join('test.mkp').write_binary(original_mkp_file)

    package = mkp.load_file(str(tmpdir.join('test.mkp')))

    assert type(package) == mkp.Package
    assert package.info['title'] == 'Title of test'
Пример #3
0
def test_dist_uses_script_path_when_no_path_is_given(tmpdir):

    script = tmpdir.join('dist.py')
    script.write_text(u'''#!/usr/bin/env python

from mkp import dist


dist({
    'author': 'John Doe',
    'name': 'foo',
    'version': '42',
})
''', 'utf-8')
    script.chmod(0o700)
    tmpdir.join('agents', 'special', 'agent_test').write_binary(b'hello', ensure=True)
    tmpdir.join('checks', 'foo').write_binary(b'Check Me!', ensure=True)

    script.sysexec()

    assert tmpdir.join('dist', 'foo-42.mkp').exists()
    package = mkp.load_file(str(tmpdir.join('dist', 'foo-42.mkp')))
    assert package.info['author'] == 'John Doe'
    assert package.info['name'] == 'foo'
    assert package.info['files']['agents'] == ['special/agent_test']
    assert package.info['files']['checks'] == ['foo']
    assert package.info['version'] == '42'
    assert package.info['version.packaged'] == 'python-mkp'
def test_load_file(original_mkp_file, tmpdir):
    tmpdir.join('test.mkp').write_binary(original_mkp_file)

    package = mkp.load_file(str(tmpdir.join('test.mkp')))

    assert type(package) == mkp.Package
    assert package.info['title'] == 'Title of test'
    assert package.json_info is None
Пример #5
0
def test_dist_json(tmpdir, sample_files, sample_info):
    mkp.dist(sample_info, str(tmpdir))

    assert tmpdir.join('dist', 'foo-42.mkp').exists()
    package = mkp.load_file(str(tmpdir.join('dist', 'foo-42.mkp')))
    assert package.json_info['author'] == 'John Doe'
    assert package.json_info['name'] == 'foo'
    assert package.json_info['files']['agents'] == ['special/agent_test']
    assert package.json_info['files']['checks'] == ['foo']
    assert package.json_info['num_files'] == 2
    assert package.json_info['version'] == '42'
    assert package.json_info['version.packaged'] == 'python-mkp'
    assert package.json_info['version.min_required'] == '1.2.6p5'
    assert package.json_info['version.usable_until'] is None
Пример #6
0
def test_dist(tmpdir):
    tmpdir.join('agents', 'special', 'agent_test').write_binary(b'hello', ensure=True)
    tmpdir.join('checks', 'foo').write_binary(b'Check Me!', ensure=True)
    info = {
        'author': 'John Doe',
        'name': 'foo',
        'version': '42',
    }

    mkp.dist(info, str(tmpdir))

    assert tmpdir.join('dist', 'foo-42.mkp').exists()
    package = mkp.load_file(str(tmpdir.join('dist', 'foo-42.mkp')))
    assert package.info['author'] == 'John Doe'
    assert package.info['name'] == 'foo'
    assert package.info['files']['agents'] == ['special/agent_test']
    assert package.info['files']['checks'] == ['foo']
    assert package.info['version'] == '42'
    assert package.info['version.packaged'] == 'python-mkp'