I got an aggregation query with $lookup
inside it:
pipeline = [{
'$match': {
'_id': ObjectId(layout_id)
}
}, {
'$lookup': {
'from': 'units',
'localField': 'unit_id',
'foreignField': '_id',
'as': 'layout_unit'
}
}, {
'$replaceRoot': {
'newRoot': {
'$mergeObjects': [{
'$arrayElemAt': ["$layout_unit", 0]
}]
}
}
}, {
'$project': {
'layout_unit': 0
}
}, {
'$lookup': {
'from': 'users',
'localField': 'user_id',
'foreignField': '_id',
'as': 'unit_user'
}
}, {
'$unwind': '$unit_user'
}]
I would like to unit-test it using mongomock
. The issue here is, that as of version 3.9.0 it doesn't support $lookup
aggregations.
NotImplementedError: Although '$lookup' is a valid operator for the aggregation pipeline, it is currently not implemented in Mongomock.
Is there a workaround to this? Or perhaps a substitute solution to mongomock
?