From 3781095f25b4e1e9130068c7bd1a72510c3f0105 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Fri, 24 Sep 2021 12:17:39 +0300 Subject: [PATCH] Change the mock database name to "db", because all of the codebase is using this database. This change enables us to write unit tests without the need to patch the the database name in all of the mongo queries that look like "mongo.db.collection" --- .../tests/unit_tests/monkey_island/cc/mongomock_fixtures.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/mongomock_fixtures.py b/monkey/tests/unit_tests/monkey_island/cc/mongomock_fixtures.py index aa00aa69a..4fac539c1 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/mongomock_fixtures.py +++ b/monkey/tests/unit_tests/monkey_island/cc/mongomock_fixtures.py @@ -1,7 +1,10 @@ import mongoengine import pytest -MOCK_DB_NAME = "mongoenginetest" +# Database name has to match the db used in the codebase, +# else the name needs to be mocked during tests. +# Currently its used like so: "mongo.db.telemetry.find()". +MOCK_DB_NAME = "db" @pytest.fixture(scope="module", autouse=True)