class Record(ndb.Model):
notes = ndb.TextProperty()
last_updated = ndb.DateTimeProperty(auto_now=True)
单元测试设置的一部分:
record2 = Record()
# trying to set the last_updated timestamp to a previous date
record2.last_updated = previous_date
record2.put()
#after saving it, the timestamp is back to today's date
因此,我无法为我的单元测试模拟旧记录。如何在不更改模型的情况下覆盖该字段?