Added test of field facets of floats and numbers.

This commit is contained in:
Jorge C. Leitão 2015-11-11 23:09:12 +01:00
parent 0bea487560
commit a3ea18207a
2 changed files with 16 additions and 0 deletions

View file

@ -365,6 +365,18 @@ class BackendFeaturesTestCase(HaystackBackendTestCase, TestCase):
self.assertEqual(results['facets']['fields']['sites'],
[('1', 1), ('3', 2), ('2', 2), ('4', 1), ('6', 2), ('9', 1)])
results = self.backend.search(xapian.Query('indexed'),
facets=['number'])
self.assertEqual(results['hits'], 3)
self.assertEqual(results['facets']['fields']['number'],
[(5, 1), (10, 1), (15, 1)])
results = self.backend.search(xapian.Query('indexed'),
facets=['float_number'])
self.assertEqual(results['hits'], 3)
self.assertEqual(results['facets']['fields']['float_number'],
[(35.5, 1), (834.0, 1), (972.0, 1)])
def test_raise_index_error_on_wrong_field(self):
"""
Regression test for #109.

View file

@ -17,6 +17,10 @@ from ..tests.test_backend import HaystackBackendTestCase
class XapianSearchQueryTestCase(HaystackBackendTestCase, TestCase):
"""
Tests the XapianSearchQuery, the class that converts SearchQuerySet queries
using the `__` notation to XapianQueries.
"""
def get_index(self):
return MockQueryIndex()