File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ class Example(models.Model):
7
7
address = models .CharField (max_length = 200 )
8
8
lat = models .FloatField ()
9
9
lng = models .FloatField ()
10
+ is_admin = models .BooleanField (default = False )
10
11
category = []
11
12
locations = []
12
13
index_me = True
@@ -27,3 +28,7 @@ def static_should_index():
27
28
@staticmethod
28
29
def static_should_not_index ():
29
30
return False
31
+
32
+ @property
33
+ def property_should_index (self ):
34
+ return True
Original file line number Diff line number Diff line change @@ -213,4 +213,18 @@ class ExampleIndex(AlgoliaIndex):
213
213
instance_should_not .index_me = False
214
214
obj = index ._build_object (instance_should_not )
215
215
self .assertFalse (index ._should_index (instance_should_not ),
216
- "We should not index an instance when its should_index attr is False" )
216
+ "We should not index an instance when its should_index attr is False" )
217
+
218
+ def test_should_index_field_raises (self ):
219
+ class ExampleIndex (AlgoliaIndex ):
220
+ fields = 'name'
221
+ should_index = 'is_admin'
222
+ with self .assertRaises (AlgoliaIndexError ):
223
+ index = ExampleIndex (Example , self .client )
224
+
225
+ def test_should_index_property_raises (self ):
226
+ class ExampleIndex (AlgoliaIndex ):
227
+ fields = 'name'
228
+ should_index = 'property_should_index'
229
+ with self .assertRaises (AlgoliaIndexError ):
230
+ index = ExampleIndex (Example , self .client )
You can’t perform that action at this time.
0 commit comments