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_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)
def test_SourceInstall(): from xylem.platforms.source import InvalidRdmanifest, SourceInstall #tripwire SourceInstall() # test unpacking of dict manifest = { 'md5sum': 'fake-md5', 'exec-path': '/path', 'install-script': 'echo hello', 'check-presence-script': 'hello there', 'uri': 'http://ros.org/', 'alternate-uri': 'http://turtlebot.com/', 'depends': ['foo', 'bar'], } resolved = SourceInstall.from_manifest(manifest, 'fake-url') assert resolved.manifest == manifest assert resolved.manifest_url == 'fake-url' assert resolved.install_command == 'echo hello' assert resolved.check_presence_command == 'hello there' assert resolved.exec_path == '/path' assert resolved.tarball == 'http://ros.org/' assert resolved.alternate_tarball == 'http://turtlebot.com/' assert resolved.tarball_md5sum == 'fake-md5' test_dir = get_test_dir() path = os.path.join(test_dir, 'rep112-example.rdmanifest') manifest = yaml.load(open(path)) resolved = SourceInstall.from_manifest(manifest, path) _subtest_rep112_rdmanifest(resolved) #TODO: test depends # test with bad dicts manifest = { 'md5sum': 'fake-md5', 'exec-path': '/path', 'install-script': 'echo hello', 'check-presence-script': 'hello there', 'alternate-uri': 'http://turtlebot.com/', 'depends': ['foo', 'bar'], } # uri is required try: SourceInstall.from_manifest(manifest, 'foo') assert False, "should have raised" except InvalidRdmanifest as e: pass # test defaults manifest = dict(uri='http://ros.org/') resolved = SourceInstall.from_manifest(manifest, 'foo') assert resolved.exec_path == '.' assert resolved.install_command == '' assert resolved.check_presence_command == '' assert resolved.alternate_tarball is None assert resolved.tarball_md5sum is None
def test_install_source(): from xylem.platforms.source import install_source, SourceInstall resolved = SourceInstall() resolved.tarball = 'https://kforge.ros.org/rosrelease/xylem/raw-file/tip/test/source/foo.tar.gz' resolved.tarball_md5sum = 'fd34dc39f8f192b97fcc191fe0a6befc' resolved.install_command = """#!/bin/sh exit 0 """ resolved.exec_path = '' install_source(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)