def test_ensure_indexes_new_style(self): """ Test the new style mongoengine index assertion where ensure_index is defined on the Document """ mock_model = MagicMock() manage._ensure_indexes(mock_model) mock_model.ensure_indexes.assert_called_once_with()
def test_ensure_indexes_old_style(self): """ Test the old style mongoengine index assertion where ensure_index is defined on the queryset """ class ModelHelper(object): def __init__(self): self.objects = MagicMock() mock_model = ModelHelper() manage._ensure_indexes(mock_model) mock_model.objects._ensure_indexes.assert_called_once_with()