From a1782de1037dc1f818c45257d978da888e87ff85 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 24 Jun 2020 14:22:58 +0200 Subject: Improve mocking logic --- opendc/util/database.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'opendc/util/database.py') diff --git a/opendc/util/database.py b/opendc/util/database.py index 24572279..50bc93a8 100644 --- a/opendc/util/database.py +++ b/opendc/util/database.py @@ -7,11 +7,13 @@ from pymongo import MongoClient DATETIME_STRING_FORMAT = '%Y-%m-%dT%H:%M:%S' CONNECTION_POOL = None -DB = None class Database: - def __init__(self, user, password, database, host): + def __init__(self): + self.opendc_db = None + + def init_database(self, user, password, database, host): user = urllib.parse.quote_plus(user) # TODO: replace this with environment variable password = urllib.parse.quote_plus(password) # TODO: same as above database = urllib.parse.quote_plus(database) @@ -88,6 +90,4 @@ class Database: return datetime.strptime(string_to_convert, DATETIME_STRING_FORMAT) -def initialize_database(user, password, database, host): - global DB - DB = Database(user, password, database, host) +DB = Database() -- cgit v1.2.3