def test_facets(self):
     queryset = TestModel.es.all()
     filter_backend = ElasticsearchFilterBackend()
     s = filter_backend.filter_queryset(self.fake_request, queryset, self.fake_view)
     expected = [{u'doc_count': 1, u'key': u'test'}]
     self.assertEqual(s.facets['doc_count'], 3)
     self.assertEqual(s.facets['first_name']['buckets'], expected)
 def test_facets(self):
     queryset = TestModel.es.all()
     filter_backend = ElasticsearchFilterBackend()
     s = filter_backend.filter_queryset(self.fake_request, queryset, self.fake_view)
     expected = [{u'doc_count': 1, u'key': u'test'}]
     self.assertEqual(s.facets['doc_count'], 3)
     self.assertEqual(s.facets['first_name']['buckets'], expected)
 def test_filter_backend_no_list(self):
     queryset = TestModel.es.all()
     filter_backend = ElasticsearchFilterBackend()
     self.fake_view.action = 'create'
     queryset = filter_backend.filter_queryset(self.fake_request, queryset, self.fake_view)
     # the 'normal' dataflow continues
     self.assertTrue(isinstance(queryset, QuerySet))
     self.fake_view.action = 'list'
 def test_filter_backend_no_list(self):
     queryset = TestModel.es.all()
     filter_backend = ElasticsearchFilterBackend()
     self.fake_view.action = 'create'
     queryset = filter_backend.filter_queryset(self.fake_request, queryset, self.fake_view)
     # the 'normal' dataflow continues
     self.assertTrue(isinstance(queryset, QuerySet))
     self.fake_view.action = 'list'
    def test_filter_backend_ordering(self):
        queryset = TestModel.es.all()
        filter_backend = ElasticsearchFilterBackend()
        self.fake_view.ordering = ('-username',)
        queryset = filter_backend.filter_queryset(self.fake_request, queryset, self.fake_view).deserialize()

        self.assertEqual(queryset[0].id, self.model2.id)
        self.assertEqual(queryset[1].id, self.model1.id)
        del self.fake_view.ordering
    def _test_filter_backend(self):
        queryset = TestModel.es.all()
        filter_backend = ElasticsearchFilterBackend()
        queryset = filter_backend.filter_queryset(self.fake_request, queryset, self.fake_view)

        l = queryset.deserialize()
        self.assertTrue(self.model1 in l)
        self.assertTrue(self.model2 in l)
        self.assertFalse(self.model3 in l)
    def test_filter_backend_ordering(self):
        queryset = TestModel.es.all()
        filter_backend = ElasticsearchFilterBackend()
        self.fake_view.ordering = ('-username',)
        queryset = filter_backend.filter_queryset(self.fake_request, queryset, self.fake_view).deserialize()

        self.assertEqual(queryset[0].id, self.model2.id)
        self.assertEqual(queryset[1].id, self.model1.id)
        del self.fake_view.ordering
    def _test_filter_backend(self):
        queryset = TestModel.es.all()
        filter_backend = ElasticsearchFilterBackend()
        queryset = filter_backend.filter_queryset(self.fake_request, queryset, self.fake_view)

        x = queryset.deserialize()
        self.assertTrue(self.model1 in x)
        self.assertTrue(self.model2 in x)
        self.assertFalse(self.model3 in x)
 def test_filter_backend_on_normal_model(self):
     filter_backend = ElasticsearchFilterBackend()
     with self.assertRaises(ValueError):
         filter_backend.filter_queryset(self.fake_request, User.objects.all(), self.fake_view)
Beispiel #10
0
 def test_filter_backend_on_normal_model(self):
     filter_backend = ElasticsearchFilterBackend()
     with self.assertRaises(ValueError):
         filter_backend.filter_queryset(self.fake_request,
                                        User.objects.all(), self.fake_view)