@@ -14,17 +14,17 @@ class SimpleMockSearchIndex(indexes.SearchIndex):
14
14
15
15
class SimpleSearchBackendTestCase (TestCase ):
16
16
fixtures = ['bulk_data.json' ]
17
-
17
+
18
18
def setUp (self ):
19
19
super (SimpleSearchBackendTestCase , self ).setUp ()
20
-
20
+
21
21
self .site = SearchSite ()
22
22
self .backend = SearchBackend (site = self .site )
23
23
self .index = SimpleMockSearchIndex (MockModel , backend = self .backend )
24
24
self .site .register (MockModel , SimpleMockSearchIndex )
25
-
25
+
26
26
self .sample_objs = MockModel .objects .all ()
27
-
27
+
28
28
def test_update (self ):
29
29
self .backend .update (self .index , self .sample_objs )
30
30
@@ -37,23 +37,23 @@ def test_clear(self):
37
37
def test_search (self ):
38
38
# No query string should always yield zero results.
39
39
self .assertEqual (self .backend .search (u'' ), {'hits' : 0 , 'results' : []})
40
-
40
+
41
41
self .assertEqual (self .backend .search (u'*' )['hits' ], 23 )
42
42
self .assertEqual ([result .pk for result in self .backend .search (u'*' )['results' ]], [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 ])
43
-
43
+
44
44
self .assertEqual (self .backend .search (u'daniel' )['hits' ], 23 )
45
45
self .assertEqual ([result .pk for result in self .backend .search (u'daniel' )['results' ]], [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 ])
46
-
46
+
47
47
self .assertEqual (self .backend .search (u'should be a string' )['hits' ], 1 )
48
48
self .assertEqual ([result .pk for result in self .backend .search (u'should be a string' )['results' ]], [8 ])
49
-
49
+
50
50
self .assertEqual (self .backend .search (u'index document' )['hits' ], 6 )
51
51
self .assertEqual ([result .pk for result in self .backend .search (u'index document' )['results' ]], [2 , 3 , 15 , 16 , 17 , 18 ])
52
-
52
+
53
53
# No support for spelling suggestions
54
54
self .assertEqual (self .backend .search (u'Indx' )['hits' ], 0 )
55
55
self .assertFalse (self .backend .search (u'Indx' ).get ('spelling_suggestion' ))
56
-
56
+
57
57
# No support for facets
58
58
self .assertEqual (self .backend .search (u'' , facets = ['name' ]), {'hits' : 0 , 'results' : []})
59
59
self .assertEqual (self .backend .search (u'daniel' , facets = ['name' ])['hits' ], 23 )
@@ -64,6 +64,9 @@ def test_search(self):
64
64
self .assertFalse (self .backend .search (u'' ).get ('facets' ))
65
65
self .assertFalse (self .backend .search (u'daniel' ).get ('facets' ))
66
66
67
+ # Note that only textual-fields are supported.
68
+ self .assertEqual (self .backend .search (u'2009-06-18' )['hits' ], 0 )
69
+
67
70
def test_more_like_this (self ):
68
71
self .backend .update (self .index , self .sample_objs )
69
72
self .assertEqual (self .backend .search (u'*' )['hits' ], 23 )
0 commit comments