def test_repository_exact_match(self): """ Test that repository slug matches exactly """ test_repo = create_repo("test", "testing", self.user.id) testing_repo = create_repo("testing", "testing", self.user.id) # Should start off with nothing in testing_repo. self.assertEqual(construct_queryset(test_repo.slug).count(), 0) self.assertEqual(construct_queryset(testing_repo.slug).count(), 0) self.import_course_tarball(test_repo) # We imported into 'test' so 'testing' shouldn't contain anything. self.assertTrue(construct_queryset(test_repo.slug).count() > 0) self.assertEqual(construct_queryset(testing_repo.slug).count(), 0)
def count_faceted_results(self, vocab, term): """Return count of matching indexed records by facet.""" facet_query = "{0}_exact:{1}".format(vocab, term) return construct_queryset( repo_slug=self.repo.slug, selected_facets=[facet_query] ).count()
def get_queryset(self): repo_slug = self.kwargs['repo_slug'] query = self.request.GET.get('q', '') selected_facets = self.request.GET.getlist('selected_facets') sortby = self.request.GET.get('sortby', '') return construct_queryset(repo_slug, query, selected_facets, sortby)
def search(self, query, sorting=LoreSortingFields.DEFAULT_SORTING_FIELD): """ Helper function to perform a search """ return construct_queryset( repo_slug=self.repo.slug, query=query, sortby=sorting)