def test_InstallerContext_os_version_and_name(): from rospkg.os_detect import OsDetect from rosdep2.installers import InstallerContext context = InstallerContext() context.set_verbose(True) os_name, os_version = context.get_os_name_and_version() assert os_name is not None assert os_version is not None val = ("fakeos", "blah") context.set_os_override(*val) assert val == context.get_os_name_and_version() from mock import Mock from rospkg.os_detect import OsDetect os_detect_mock = Mock(spec=OsDetect) os_detect_mock.get_name.return_value = 'fakeos' os_detect_mock.get_version.return_value = 'fakeos-version' os_detect_mock.get_codename.return_value = 'fakeos-codename' context = InstallerContext(os_detect_mock) context.set_os_version_type('fakeos', os_detect_mock.get_codename) os_name, os_version = context.get_os_name_and_version() assert os_name == 'fakeos', os_name assert os_version == 'fakeos-codename', os_version context.set_os_version_type('fakeos', os_detect_mock.get_version) os_name, os_version = context.get_os_name_and_version() assert os_name == 'fakeos', os_name assert os_version == 'fakeos-version', os_version
def test_InstallerContext_os_version_and_name(): from rosdep2.installers import InstallerContext, TYPE_CODENAME, TYPE_VERSION context = InstallerContext() context.set_verbose(True) os_name, os_version = context.get_os_name_and_version() assert os_name is not None assert os_version is not None val = ("fakeos", "blah") context.set_os_override(*val) assert val == context.get_os_name_and_version() from mock import Mock from rospkg.os_detect import OsDetect os_detect_mock = Mock(spec=OsDetect) os_detect_mock.get_name.return_value = 'fakeos' os_detect_mock.get_version.return_value = 'fakeos-version' os_detect_mock.get_codename.return_value = 'fakeos-codename' context = InstallerContext(os_detect_mock) context.set_os_version_type('fakeos', TYPE_CODENAME) os_name, os_version = context.get_os_name_and_version() assert os_name == 'fakeos', os_name assert os_version == 'fakeos-codename', os_version context.set_os_version_type('fakeos', TYPE_VERSION) os_name, os_version = context.get_os_name_and_version() assert os_name == 'fakeos', os_name assert os_version == 'fakeos-version', os_version
def test_RosdepLookup_resolve_all_errors(): from rosdep2.installers import InstallerContext from rosdep2.lookup import RosdepLookup, ResolutionError rospack, rosstack = get_test_rospkgs() sources_loader = create_test_SourcesListLoader() lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rosstack, sources_loader=sources_loader) # the installer context has nothing in it, lookups will fail installer_context = InstallerContext() installer_context.set_os_override('ubuntu', 'lucid') resolutions, errors = lookup.resolve_all(['rospack_fake'], installer_context) assert 'rospack_fake' in errors resolutions, errors = lookup.resolve_all(['not_a_resource'], installer_context) assert 'not_a_resource' in errors, errors
def test_RosdepLookup_resolve_errors(): from rosdep2.installers import InstallerContext from rosdep2.lookup import RosdepLookup, ResolutionError rospack, rosstack = get_test_rospkgs() sources_loader = create_test_SourcesListLoader() lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rosstack, sources_loader=sources_loader) # the installer context has nothing in it, lookups will fail installer_context = InstallerContext() installer_context.set_os_override('ubuntu', 'lucid') try: lookup.resolve('testtinyxml', 'rospack_fake', installer_context) assert False, "should have raised" except ResolutionError as e: assert "Unsupported OS" in str(e), str(e) try: lookup.resolve('fakedep', 'rospack_fake', installer_context) assert False, "should have raised" except ResolutionError as e: assert "Cannot locate rosdep definition" in str(e), str(e)
def test_RosdepLookup_resolve_errors(): from rosdep2.installers import InstallerContext from rosdep2.lookup import RosdepLookup, ResolutionError rospack, rosstack = get_test_rospkgs() sources_loader = create_test_SourcesListLoader() lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rosstack, sources_loader=sources_loader) # the installer context has nothing in it, lookups will fail installer_context = InstallerContext() installer_context.set_os_override('ubuntu', 'lucid') try: lookup.resolve('testtinyxml', 'rospack_fake', installer_context) assert False, 'should have raised' except ResolutionError as e: assert 'Unsupported OS' in str(e), str(e) try: lookup.resolve('fakedep', 'rospack_fake', installer_context) assert False, 'should have raised' except ResolutionError as e: assert 'Cannot locate rosdep definition' in str(e), str(e)