Merge pull request #36811 from sebastian-philipp/mgr-always-mock-rados

pybind/mgr: pytest: Unconditionally mock the rados objects

Reviewed-by: Ernesto Puerta <epuertat@redhat.com>
Reviewed-by: Jan Fajerski <jfajerski@suse.com>
This commit is contained in:
Sebastian Wagner 2020-08-27 14:50:46 +02:00 committed by GitHub
commit 48834128ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 9 deletions

View File

@ -2,6 +2,5 @@ import os
if 'UNITTEST' in os.environ:
import tests
tests.mock_ceph_modules() # type: ignore
from .module import CephadmOrchestrator

View File

@ -38,12 +38,10 @@ else:
os.environ['PATH'] = '{}:{}'.format(os.path.abspath('../../../../build/bin'),
os.environ['PATH'])
from tests import mock, mock_ceph_modules # type: ignore
from tests import mock # type: ignore
mgr = mock.Mock()
mgr.get_frontend_path.side_effect = lambda: os.path.abspath("./frontend/dist")
mock_ceph_modules()
# DO NOT REMOVE: required for ceph-mgr to load a module
from .module import Module, StandbyModule # noqa: F401

View File

@ -2,6 +2,5 @@ import os
if 'UNITTEST' in os.environ:
import tests
tests.mock_ceph_modules() # type: ignore
from .module import MDSAutoscaler

View File

@ -1,8 +1,12 @@
import os
if 'UNITTEST' in os.environ:
import tests
import cephfs
import contextlib
import datetime
import errno
import os
import socket
import time
import logging

View File

@ -189,4 +189,7 @@ if 'UNITTEST' in os.environ:
'rados': mock.MagicMock(Error=MockRadosError, OSError=MockRadosError),
'rbd': mock.Mock(),
'cephfs': mock.Mock(),
})
})
# Unconditionally mock the rados objects when we're imported
mock_ceph_modules() # type: ignore

View File

@ -28,8 +28,6 @@ addopts =
[testenv]
setenv =
UNITTEST = true
PYTHONPATH = ../../../build/lib/cython_modules/lib.3/
LD_LIBRARY_PATH = ../../../build/lib
deps =
cython
-rrequirements.txt