Can anyone suggest a way to examine why my code is failing the test.
I am getting an assertion error that the lastupdated
field is not of type datetime
.
assert isinstance(result.get('lastupdated'), datetime)
AssertionError: assert False
+ where False = isinstance('2015-02-03 00:25:58.217000000', datetime)
I have set my predicate and tested it out in Compass and a Jupyter notebook. By running the file without the bulk_updates
operation I get 45993 documents to migrate
, so my predicate is picking up all the documents.
The first document in movies_to_be_migrated
is:
{'doc_id': ObjectId('573a1390f29313caabcd4132'), 'lastupdated': datetime.datetime(2015, 8, 26, 0, 3, 45, 40000)}
So parser.parse(lastupdated)
has worked.
For the bulk updates, the first document to be updated is:
UpdateOne({'_id': ObjectId('573a1390f29313caabcd4132')}, {'$set': {'lastupdated': datetime.datetime(2015, 8, 26, 0, 3, 45, 40000)}}, False, None, None)
The value to be updated is a datetime.datetime
object. The final 3 parameters are the pymongo defaults of upsert=False, collation=None, array_filters=None
So, in conclusion,
-
I’m updating all the docments
-
The lastupdated
is being converted
-
The update should be overwriting the existing string
with a datetime.datetime
object
-
But the vaildation test fails.
-
The inference is that my $set
is incorrect and no documents are actually being updated. I’ve tested out the format in a Jupyter notebook and it seems to be correct.
Anyone got any ideas?
Thanks