Fixed UT's for models by mocking an environment singleton with needed mongodb parameters
This commit is contained in:
parent
5b7329b3d1
commit
17e994c8d8
|
@ -12,6 +12,7 @@ from .monkey import Monkey # noqa: F401, E402
|
|||
from .monkey_ttl import MonkeyTtl # noqa: F401, E402
|
||||
from .pba_results import PbaResults # noqa: F401, E402
|
||||
|
||||
# TODO refactor into explicit call when implementing mongodb startup
|
||||
connect(
|
||||
db=env_singleton.env.mongo_db_name,
|
||||
host=env_singleton.env.mongo_db_host,
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
import monkey_island.cc.environment.environment_singleton as env_singleton
|
||||
from monkey_island.cc.environment.testing import TestingEnvironment
|
||||
|
||||
# Mock environment singleton because it contains mongodb parameters
|
||||
# needed for model tests. See monkey/monkey_island/cc/models/__init__.py
|
||||
env_config = {}
|
||||
env_singleton.env = TestingEnvironment(env_config)
|
||||
|
||||
# Without these imports pytests can't use fixtures,
|
||||
# because they are not found
|
||||
from tests.unit_tests.monkey_island.cc.mongomock_fixtures import * # noqa: F401,F403
|
||||
from tests.unit_tests.monkey_island.cc.mongomock_fixtures import * # noqa: F401,F403,E402
|
||||
|
|
Loading…
Reference in New Issue