Last active
July 26, 2016 20:15
-
-
Save jaraco/dddc5a70523dba9fc127162ca70e6c75 to your computer and use it in GitHub Desktop.
Test attempting to replicate /whit537/mongs/issues/32
This file contains hidden or 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
__requires__ = ['jaraco.mongodb', 'pymongo==3.2.2', 'pytest'] | |
import pytest | |
import sys | |
import bson | |
def test_issue(mongodb_instance): | |
coll = mongodb_instance.get_connection()['test_db']['test_coll'] | |
explicit_id = bson.ObjectId() | |
# insert id as string | |
id = coll.insert({'_id': str(explicit_id), 'foo': 'bar'}) | |
assert isinstance(id, str) | |
constructed_id = bson.ObjectId(id) | |
assert explicit_id == constructed_id | |
doc = coll.find_one(str(id)) | |
assert doc['foo'] == 'bar' | |
doc = coll.find_one(constructed_id) | |
assert doc is None | |
__name__ == '__main__' and pytest.main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment