How Do I Refresh An Ndb Entity From The Datastore?
I'd like to be able to assert in tests that my code called Model.put() for the entities that were modified. Unfortunately, there seems to be some caching going on, such that this c
Solution 1:
You can bypass the caching like this:
entity = key.get(use_cache=False, use_memcache=False)
These options are from ndb's context options. They can be applied to Model.get_by_id()
, Model.query().fetch()
and Model.query().get()
too
Solution 2:
Your current test validates the "local", in-memory version of your entity (independent of what's in the datastore). You should re-fetch the entity from NDB before your checks:
new_entity = entity.key.get()
assert [...]
Post a Comment for "How Do I Refresh An Ndb Entity From The Datastore?"