Skip to content

Commit

Permalink
adapt mongoengine config change
Browse files Browse the repository at this point in the history
  • Loading branch information
jokester committed Oct 15, 2024
1 parent 86690ef commit 54e10d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .env.test.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SITE_NAME=萌翻TEST
SECRET_KEY=SECRET
[email protected]

MONGODB_URI="mongomock://moeflow:[email protected]:27017/moeflow_test?authSource=admin"
MONGODB_URI="mongodb://moeflow:[email protected]:27017/moeflow_test?authSource=admin"
# MONGODB_DB_NAME=moeflow
# MONGODB_USER=moeflow
# MONGODB_PASS=CHANGE_ME
Expand Down
5 changes: 5 additions & 0 deletions app/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def connect_db(config):
logger.info("Connect mongodb")
uri = config["DB_URI"]
logger.debug(" - $DB_URI: {}".format(uri))
if config.get("TESTING"):
import mongomock

return connect(host=uri, mongo_client_class=mongomock.MongoClient)

return connect(host=uri)


Expand Down

0 comments on commit 54e10d6

Please sign in to comment.