コード例 #1
0
def test_source_detect():
    from xylem.platforms.source import source_detect, SourceInstall
    resolved = SourceInstall()
    resolved.check_presence_command = """#!/bin/bash
exit 0
"""
    assert [] == source_detect([])
    assert [resolved] == source_detect([resolved])

    def yes(*args, **kwds):
        return 0

    def no(*args, **kwds):
        return 1

    resolved = [
        SourceInstall(),
        SourceInstall(),
        SourceInstall(),
        SourceInstall()
    ]
    for r in resolved:
        r.check_presence_command = ''

    retval = source_detect(resolved, exec_fn=yes)
    assert resolved == retval, retval
    assert [] == source_detect(resolved, exec_fn=no)
コード例 #2
0
def test_is_installed():
    from xylem.platforms.source import SourceInstaller, SourceInstall
    resolved = SourceInstall()
    resolved.check_presence_command = """#!/bin/bash
exit 0
"""
    installer = SourceInstaller()
    assert installer.is_installed(resolved)
コード例 #3
0
def test_SourceInstaller_get_install_command():
    from xylem.platforms.source import SourceInstaller, SourceInstall
    installer = SourceInstaller()

    resolved = SourceInstall()
    resolved.manifest_url = 'http://fake/foo'
    resolved.check_presence_command = """#!/bin/bash
exit 1
"""
    commands = installer.get_install_command([resolved])
    assert len(commands) == 1
    assert commands[0] == ['xylem-source', 'install', 'http://fake/foo']

    resolved = SourceInstall()
    resolved.manifest_url = 'http://fake/foo'
    resolved.check_presence_command = """#!/bin/bash
exit 0
"""
    commands = installer.get_install_command([resolved])
    assert not (commands)