-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Tests for supporting `mongodb+srv://` URIs""" | ||
|
||
from pytest import fixture | ||
|
||
from abcd import ABCD | ||
from abcd.backends.atoms_pymongo import MongoDatabase | ||
|
||
|
||
@fixture | ||
def mongo_srv(mocker): | ||
# mongomock does not pick up what we need, so this is a bespoke mocker | ||
mock_client = mocker.MagicMock() | ||
mocker.patch("abcd.backends.atoms_pymongo.MongoClient", mock_client) | ||
return mock_client | ||
|
||
|
||
def test_init_mongodb_srv(mongo_srv): | ||
# client can be created with a mongodb+srv:// URI | ||
|
||
# regression test | ||
uri = "mongodb+srv://user:[email protected]/?key=value" | ||
|
||
# create the client | ||
abcd = ABCD.from_url(uri) | ||
|
||
assert isinstance(abcd, MongoDatabase) | ||
mongo_srv.assert_called_once_with(host=uri, authSource="admin") |