summaryrefslogtreecommitdiff
path: root/opendc/util/database.py
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-06-24 14:22:58 +0200
committerGeorgios Andreadis <info@gandreadis.com>2020-06-24 14:22:58 +0200
commita1782de1037dc1f818c45257d978da888e87ff85 (patch)
tree1c80597a51d7571d3449698bf5bb209a96fe2bdb /opendc/util/database.py
parentdb979d36d0b9693cc81ffa0bdd29364c6218fc95 (diff)
Improve mocking logic
Diffstat (limited to 'opendc/util/database.py')
-rw-r--r--opendc/util/database.py10
1 files changed, 5 insertions, 5 deletions
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()