Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_InstallerContext_ctor():
from rosdep2.installers import InstallerContext
from rospkg.os_detect import OsDetect
context = InstallerContext()
assert context.get_os_detect() is not None
assert isinstance(context.get_os_detect(), OsDetect)
detect = OsDetect()
context = InstallerContext(detect)
assert context.get_os_detect() == detect
assert len(context.get_installer_keys()) == 0
assert len(context.get_os_keys()) == 0
context.verbose = True
assert context.get_os_detect() == detect
assert len(context.get_installer_keys()) == 0
assert len(context.get_os_keys()) == 0
def test_Fedora_variable_lookup_key():
from rosdep2 import InstallerContext
from rosdep2.platforms import pip, redhat, source
from rosdep2.platforms.redhat import DNF_INSTALLER, YUM_INSTALLER
from rospkg.os_detect import OsDetect, OS_FEDORA
os_detect_mock = Mock(spec=OsDetect)
os_detect_mock.get_name.return_value = 'fedora'
os_detect_mock.get_codename.return_value = 'heisenbug'
os_detect_mock.get_version.return_value = '20'
# create our test fixture. use most of the default toolchain, but
# replace the apt installer with one that we can have more fun
# with. we will do all tests with ubuntu lucid keys -- other
# tests should cover different resolution cases.
context = InstallerContext(os_detect_mock)
pip.register_installers(context)
redhat.register_installers(context)
source.register_installers(context)
redhat.register_platforms(context)
assert ('fedora', 'heisenbug') == context.get_os_name_and_version()
def test_InstallerContext_installers():
from rosdep2.installers import InstallerContext, Installer
from rospkg.os_detect import OsDetect
detect = OsDetect()
context = InstallerContext(detect)
context.verbose = True
key = 'fake-apt'
try:
installer = context.get_installer(key)
assert False, 'should have raised: %s' % (installer)
except KeyError:
pass
class Foo:
pass
class FakeInstaller(Installer):
pass
def test_InstallerContext_os_installers():
from rosdep2.installers import InstallerContext, Installer
from rospkg.os_detect import OsDetect
detect = OsDetect()
context = InstallerContext(detect)
context.verbose = True
os_key = 'ubuntu'
try:
context.get_os_installer_keys(os_key)
assert False, 'should have raised'
except KeyError:
pass
try:
context.get_default_os_installer_key(os_key)
assert False, 'should have raised'
except KeyError:
pass
try:
context.add_os_installer_key(os_key, 'fake-key')