Fixed typo and added some documentation.

This commit is contained in:
Shay Nehmad 2019-11-08 16:30:43 +02:00
parent 0acec95c86
commit ad1e85f867
3 changed files with 6 additions and 2 deletions

View File

@ -18,7 +18,7 @@ install:
- pip install -r monkey/infection_monkey/requirements_linux.txt # for unit tests
before_script:
# Set the server config to `testing`, for the UTs to use mongomaock and pass.
# Set the server config to `testing`. This is required for for the UTs to pass.
- python monkey/monkey_island/cc/set_server_config.py testing
script:

View File

@ -2,6 +2,10 @@ from monkey_island.cc.environment import Environment
class TestingEnvironment(Environment):
"""
Use this environment for running Unit Tests.
This will cause all mongo connections to happen via `mongomock` instead of using an actual mongodb instance.
"""
def __init__(self):
super(TestingEnvironment, self).__init__()
self.testing = True

View File

@ -6,7 +6,7 @@ from monkey_island.cc.environment.environment import env
# If testing, use mongomock which only emulates mongo. for more information, see
# http://docs.mongoengine.org/guide/mongomock.html .
# Otherwise, use an actual mongod instance with connection parameters supplied by env.
if env.testing:
if env.testing: # See monkey_island.cc.environment.testing
connect('mongoenginetest', host='mongomock://localhost')
else:
connect(db=env.mongo_db_name, host=env.mongo_db_host, port=env.mongo_db_port)