diff --git a/monkey/monkey_island/cc/models/__init__.py b/monkey/monkey_island/cc/models/__init__.py index 602d815c4..a46e5bd76 100644 --- a/monkey/monkey_island/cc/models/__init__.py +++ b/monkey/monkey_island/cc/models/__init__.py @@ -1,16 +1,24 @@ from mongoengine import connect -import monkey_island.cc.environment.environment_singleton as env_singleton +# Needed so that a server_config.json file exists at the default path, +# otherwise, unit tests will error while importing `env_singleton` below. +from monkey_island.cc.environment.server_config_generator import ( # noqa: E402 + create_default_server_config_file, +) -from .command_control_channel import CommandControlChannel # noqa: F401 +create_default_server_config_file() + +import monkey_island.cc.environment.environment_singleton as env_singleton # noqa: E402 + +from .command_control_channel import CommandControlChannel # noqa: F401, E402 # Order of importing matters here, for registering the embedded and referenced documents before # using them. -from .config import Config # noqa: F401 -from .creds import Creds # noqa: F401 -from .monkey import Monkey # noqa: F401 -from .monkey_ttl import MonkeyTtl # noqa: F401 -from .pba_results import PbaResults # noqa: F401 +from .config import Config # noqa: F401, E402 +from .creds import Creds # noqa: F401, E402 +from .monkey import Monkey # noqa: F401, E402 +from .monkey_ttl import MonkeyTtl # noqa: F401, E402 +from .pba_results import PbaResults # noqa: F401, E402 connect( db=env_singleton.env.mongo_db_name,