소스 검색

Split of the connect function to create a connection function that return a MongoClient object

This is used for the tests that needs to have access to a connection to be able to drop the test databases
Roland Haroutiounian 8 년 전
부모
커밋
ca6af9432b
1개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 6
    3
      plugins/mongodb_datasource/utils.py

+ 6
- 3
plugins/mongodb_datasource/utils.py 파일 보기

@@ -54,10 +54,13 @@ def connection_string(host, port, db_name, username, password):
54 54
     return 'mongodb://%s:%s@%s:%s' % (username, password, host, port)
55 55
 
56 56
 
57
+def connection(host, port, username, password):
58
+    return MongoClient(connection_string(host, port, '', username, password))
59
+
60
+
57 61
 def connect(host, port, db_name, username, password):
58
-    connection = MongoClient(
59
-        connection_string(host, port, db_name, username, password))
60
-    database = connection[db_name]
62
+    conn = connection(host, port, username, password)
63
+    database = conn[db_name]
61 64
     return database
62 65
 
63 66
 

Loading…
취소
저장