lago icon indicating copy to clipboard operation
lago copied to clipboard

Unit test tries to access /var/lib/lago/subnets

Open galitf opened this issue 6 years ago • 0 comments

We should use a mock object for the subnet store, not using the real one.

===================================================================================================== ERRORS ======================================================================================================
________________________________________________________ ERROR at setup of TestPrefixNetworkInitalization.test_select_mgmt_networks_single_network[conf0] _________________________________________________________

    @pytest.fixture
    def empty_prefix():
>       return lago.prefix.Prefix(prefix='')

tests/unit/lago/conftest.py:17: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py27/lib/python2.7/site-packages/lago/prefix.py:114: in __init__
    self._subnet_store = subnet_lease.SubnetStore()
.tox/py27/lib/python2.7/site-packages/lago/subnet_lease.py:99: in __init__
    self._validate_lease_dir()
.tox/py27/lib/python2.7/site-packages/lago/subnet_lease.py:117: in _validate_lease_dir
    e
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

exc = LagoSubnetLeaseBadPermissionsException('\nFailed to get access to the store at...this\ndirectory and that it exists.\n\nOriginal Exception: Permission denied',), cause = OSError(13, 'Permission denied')

    def raise_from(exc, cause):
        """
            Equivalent to:
    
                raise EXCEPTION from CAUSE
    
            on Python 3. (See PEP 3134).
            """
        # Is either arg an exception class (e.g. IndexError) rather than
        # instance (e.g. IndexError('my message here')? If so, pass the
        # name of the class undisturbed through to "raise ... from ...".
        if isinstance(exc, type) and issubclass(exc, Exception):
            e = exc()
            # exc = exc.__name__
            # execstr = "e = " + _repr_strip(exc) + "()"
            # myglobals, mylocals = _get_caller_globals_and_locals()
            # exec(execstr, myglobals, mylocals)
        else:
            e = exc
        e.__suppress_context__ = False
        if isinstance(cause, type) and issubclass(cause, Exception):
            e.__cause__ = cause()
            e.__suppress_context__ = True
        elif cause is None:
            e.__cause__ = None
            e.__suppress_context__ = True
        elif isinstance(cause, BaseException):
            e.__cause__ = cause
            e.__suppress_context__ = True
        else:
            raise TypeError("exception causes must derive from BaseException")
        e.__context__ = sys.exc_info()[1]
>       raise e
E       LagoSubnetLeaseBadPermissionsException: 
E       Failed to get access to the store at /var/lib/lago/subnets.
E       Please make sure that you have R/W permissions to this
E       directory and that it exists.
E       
E       Original Exception: Permission denied

.tox/py27/lib/python2.7/site-packages/future/utils/__init__.py:454: LagoSubnetLeaseBadPermissionsException
________________________________________________________ ERROR at setup of TestPrefixNetworkInitalization.test_select_mgmt_networks_single_network[conf1] ___________

galitf avatar Jun 17 '18 09:06 galitf