providers.testing.new_mock_dao_class()
Produce a mock DAO for the given DTO model and ID field.
Usage
providers.testing.new_mock_dao_class(
*,
dto_model,
id_field,
handle_mql=True,
)If handle_mql is True, the DAO will attempt to resolve query mappings that use MongoDB query language predicates (e.g. $ne, $in, $ge, etc.). Not all MQL operators are supported. Please see SUPPORTED_MQL_OPERATORS for a complete list of the currently supported MQL operators.
The MQL support is a testing aid, not an emulation of MongoDB. Operators follow Python semantics, except where MongoDB’s behavior is common in service code and simple to match, such as comparing against null or missing fields. Other edge cases, like ordering values of different types, may raise or match differently than MongoDB. Cover those with integration tests against MongoDB instead.