@@ -17,6 +17,10 @@ def setUp(self):
17
17
lat = 63.3 ,
18
18
lng = - 32.0 )
19
19
self .instance .category = ['Shop' , 'Grocery' ]
20
+ self .instance .locations = [
21
+ {'lat' : 10.3 , 'lng' : - 20.0 },
22
+ {'lat' : 22.3 , 'lng' : 10.0 },
23
+ ]
20
24
21
25
def test_default_index_name (self ):
22
26
index = AlgoliaIndex (Example , self .client )
@@ -60,6 +64,26 @@ class ExampleIndex(AlgoliaIndex):
60
64
obj = index ._build_object (self .instance )
61
65
self .assertEqual (obj ['_geoloc' ], {'lat' : 63.3 , 'lng' : - 32.0 })
62
66
67
+ def test_several_geo_fields (self ):
68
+ class ExampleIndex (AlgoliaIndex ):
69
+ geo_field = 'geolocations'
70
+
71
+ index = ExampleIndex (Example , self .client )
72
+ obj = index ._build_object (self .instance )
73
+ self .assertEqual (obj ['_geoloc' ], [
74
+ {'lat' : 10.3 , 'lng' : - 20.0 },
75
+ {'lat' : 22.3 , 'lng' : 10.0 },
76
+ ])
77
+
78
+ def test_geo_fields_already_formatted (self ):
79
+ class ExampleIndex (AlgoliaIndex ):
80
+ geo_field = 'geolocations'
81
+
82
+ self .instance .locations = {'lat' : 10.3 , 'lng' : - 20.0 }
83
+ index = ExampleIndex (Example , self .client )
84
+ obj = index ._build_object (self .instance )
85
+ self .assertEqual (obj ['_geoloc' ], {'lat' : 10.3 , 'lng' : - 20.0 })
86
+
63
87
def test_none_geo_fields (self ):
64
88
class ExampleIndex (AlgoliaIndex ):
65
89
geo_field = 'location'
0 commit comments