Conditions | 3 |
Total Lines | 11 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | # # Package # # |
||
13 | def connect(uri: str, database: str, mock: bool = False) -> None: |
||
14 | if mock: |
||
15 | try: |
||
16 | import mongomock |
||
17 | except ImportError: |
||
18 | raise RuntimeError("Mongomock needs to be installed for mocking a connection") |
||
19 | MongomanticClient.client = mongomock.MongoClient(uri) |
||
20 | else: |
||
21 | MongomanticClient.client = MongoClient(uri) |
||
22 | |||
23 | MongomanticClient.db = MongomanticClient.client.__getattr__(database) |
||
24 | |||
28 |