Comments (1)
I tried to isolate and reproduce the problem you described, but I couldn't. Here is the code I used in my test. I removed all pieces of code not relevant to the described issue. Tested on Python 3.12 and both mongomock 4.0.0 and 4.1.2
import mongomock
import pytest
from bson import ObjectId
DOC_DB_NAME = "mydatabasename"
DOC_DB_VERSION_HISTORY_COLLECTION = "mycollectionname"
@pytest.fixture
def database():
db = mongomock.MongoClient()
database = db[DOC_DB_NAME]
yield database
db.drop_database(database)
def test_get_revision_history(database):
coll_vh = database[DOC_DB_VERSION_HISTORY_COLLECTION]
coll_vh.insert_one(
{
"revision_for": ObjectId("65780d19d8df6164d4f356ad"),
"source_collection": "datacollection",
"current_revision": 2,
# e.t.c
}
)
item = coll_vh.find_one({"revision_for": ObjectId("65780d19d8df6164d4f356ad")})
assert item is not None
The test passes, so it doesn't seem to be an issue with the mongomock. I suggest you check if the MongoClient object you set in a mock and one you access later are the same object. The way you set up the test and use global module to store and retrieve the client suggests me the problem could be with the mocking.
from mongomock.
Related Issues (20)
- Add support for $where in query
- Add support for $let operator
- allowDiskUse not supported
- Add support for $redact within aggregation pipeline
- $count within $group stage of aggregation
- Clean the data after each test HOT 2
- validate_is_mapping when UpdateOne criteria is a list
- Add support for $addToSet with bool value HOT 1
- Although `$replaceWith` is a valid operator for the aggregation pipeline, it is currently not implemented in Mongomock HOT 1
- Unexpected error in aggregation $multiply
- Inconsistent behavior of list_collection_names() with and without filter
- Different behavior of mongo motor on find method with aggregation
- Add support for new aggregation operators
- When will be a new version? HOT 1
- What tox version should be used?
- Objects implementing MutableMapping which are not dicts can't be searched for
- projecting a computed field from embedded documents returns wrong result
- Modification of dict after $slice projection automatically modifies database
- 4.1.3 is not published HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongomock.