Added unit test for db dir creation.

This commit is contained in:
VakarisZ 2021-05-25 13:53:22 +03:00
parent 2483691b8b
commit 5ec64ef189
2 changed files with 24 additions and 24 deletions

View File

@ -1,24 +0,0 @@
import os
from monkey_island.cc.setup.mongo_setup import _create_db_dir
def test_create_db_dir(monkeypatch, tmpdir):
test_dir_name = "test_dir"
monkeypatch.setattr("monkey_island.cc.setup.mongo_setup.DB_DIR_NAME", test_dir_name)
expected_path = os.path.join(tmpdir, test_dir_name)
db_path = _create_db_dir(tmpdir)
assert os.path.isdir(expected_path)
assert db_path == expected_path
def test_create_db_dir_already_created(monkeypatch, tmpdir):
test_dir_name = "test_dir"
monkeypatch.setattr("monkey_island.cc.setup.mongo_setup.DB_DIR_NAME", test_dir_name)
expected_path = os.path.join(tmpdir, test_dir_name)
os.mkdir(expected_path)
db_path = _create_db_dir(tmpdir)
assert os.path.isdir(expected_path)
assert db_path == expected_path

View File

@ -0,0 +1,24 @@
import os
from monkey_island.cc.setup.mongo_process_runner import MongoDbRunner
def test_create_db_dir(monkeypatch, tmpdir):
test_dir_name = "test_dir"
monkeypatch.setattr("monkey_island.cc.setup.mongo_process_runner.DB_DIR_NAME", test_dir_name)
expected_path = os.path.join(tmpdir, test_dir_name)
db_path = MongoDbRunner(tmpdir, tmpdir)._create_db_dir()
assert os.path.isdir(expected_path)
assert db_path == expected_path
def test_create_db_dir__already_created(monkeypatch, tmpdir):
test_dir_name = "test_dir"
monkeypatch.setattr("monkey_island.cc.setup.mongo_process_runner.DB_DIR_NAME", test_dir_name)
expected_path = os.path.join(tmpdir, test_dir_name)
os.mkdir(expected_path)
db_path = MongoDbRunner(tmpdir, tmpdir)._create_db_dir()
assert os.path.isdir(expected_path)
assert db_path == expected_path