From 13e08b661f165e1fa9b12f227b6b91371b2c0b27 Mon Sep 17 00:00:00 2001 From: Alexander King Date: Thu, 29 Jun 2023 13:09:06 -0500 Subject: [PATCH] Use mock mongo client Connect MongoEngine with mongomock to test connections from a configuration. --- tests/test_util.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/test_util.py b/tests/test_util.py index 63851f8..458cb1b 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,8 +1,7 @@ """Test the functionality of the util sub-module.""" # Third-Party Libraries -from mongoengine import connect -from mongomock import MongoClient +import mongomock import pytest # cisagov Libraries @@ -34,8 +33,4 @@ def test_load_config_valid(): def test_connect_from_config_valid(valid_config): """Test that a valid configuration connects to appropriate connections.""" - connections = valid_config["connections"] - for alias in connections.keys(): - connect( - host=connections[alias]["uri"], mongo_client_class=MongoClient, alias=alias - ) + util.connect_from_config(valid_config, mongomock.MongoClient)