def test_query(self, query_class): session = Mock() registry = Mock() query_extension = Mock(autospec=_QueryExtensions) query_extension.methods = {} registry.queryUtility.return_value = query_extension repo = Repo(registry, session) subject = Mock() rv = repo.query(subject) assert isinstance(rv, Query) query_class.assert_called_once_with(session, subject, {})
def get_repo_mock(registry=None, session=None, query_extensions=None): if not session: session = Mock() if not registry: registry = Mock() if not query_extensions: query_extensions = {} query_extension = Mock(autospec=_QueryExtensions) query_extension.methods = query_extensions registry.queryUtility.return_value = query_extension repo = Repo(registry, session) return repo