def test_SourceInstaller_resolve(): from xylem.platforms.source import SourceInstaller, InvalidData test_dir = get_test_dir() url = 'https://kforge.ros.org/rosrelease/xylem/raw-file/908818f28156/test/source/rep112-example.rdmanifest' md5sum_good = 'af0dc0e2d0c0c3181dd7670c4147f155' md5sum_bad = 'fake' installer = SourceInstaller() try: installer.resolve({}) assert False, "should have raised" except InvalidData: pass try: installer.resolve(dict(uri=url, md5sum=md5sum_bad)) assert False, "should have raised" except InvalidData: pass resolved = installer.resolve(dict(uri=url, md5sum=md5sum_good)) assert type(resolved) == list assert len(resolved) == 1 resolved = resolved[0] assert resolved.install_command == rep122_install_command assert resolved.check_presence_command == rep122_check_presence_command # test again to activate caching resolved = installer.resolve(dict(uri=url, md5sum=md5sum_good)) assert resolved.install_command == rep122_install_command assert resolved.check_presence_command == rep122_check_presence_command
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)
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)