# Path: dopplr/solr/query/spatial.py
# class BoundingBoxSpatialQuery(SpatialQuery):
#     """
#     `BoundingBoxSpatialQuery` to search with bbox functionality
#     param lat the latitute point part
#     param lon the lontitude point part
#     param sfield the location type field
#     param distance the radius around the given location
#     """
#     def __init__(self, lat, lon, sfield, distance=5):
#         super(BoundingBoxSpatialQuery, self).__init__(lat, lon, sfield,
#             function_type='bbox', distance=distance)
# 
# Path: dopplr/solr/query/spatial.py
# class GeofiltSpatialQuery(SpatialQuery):
#     """
#     `GeofiltSpatialQuery` to search with geofilt functionality
#     param lat the latitute point part
#     param lon the lontitude point part
#     param sfield the location type field
#     param distance the radius around the given location
#     """
#     def __init__(self, lat, lon, sfield, distance=5):
#         super(GeofiltSpatialQuery, self).__init__(lat, lon, sfield,
#             function_type='geofilt', distance=distance)
# 
# Path: dopplr/solr/query/spatial.py
# class SpatialQuery(BaseQuery):
#     """
#     `SpatialQuery` to search with geolocations
#     param lat the latitute point part
#     param lon the lontitude point part
#     param sfield the location type field
#     param function_type is one of {geofilt, bbox}
#     param distance the radius around the given location
#     """
#     def __init__(self, lat, lon, sfield, function_type='geofilt', distance=5):
#         super(SpatialQuery, self).__init__()
#         self.__lat = lat
#         self.__lon = lon
#         self.__sfield = sfield
#         self.__function_type = function_type
#         self.__distance = distance
# 
#     def get_params(self):
#         params = []
#         params.append(('fq', '{!%s}' % (self.__function_type)))
#         params.append(('sfield', self.__sfield))
#         params.append(('pt', '%s,%s' % (self.__lat, self.__lon)))
#         params.append(('d', self.__distance))
#         return params


from pyvows import Vows, expect
from dopplr.solr.query import BoundingBoxSpatialQuery
from dopplr.solr.query import GeofiltSpatialQuery
from dopplr.solr.query import SpatialQuery

@Vows.batch
class TheSpatialQuery(Vows.Context):

    class WithDefaultParams(Vows.Context):

        def topic(self):
            lat = 0.0
            lon = 0.0
            sfield = "my_field"
            return SpatialQuery(lat, lon, sfield).get_params()

        def mustIncludeFunctionTypeParameter(self, topic):
            expect(topic).to_include(('fq', '{!geofilt}'))

        def mustIncludeCorrectlyFormattedPoint(self, topic):
            expect(topic).to_include(('pt', '0.0,0.0'))

        def mustIncludeDistanceParameter(self, topic):
            expect(topic).to_include(('d', 5))

        def mustIncludeSpatialFieldParameter(self, topic):
            expect(topic).to_include(('sfield', 'my_field'))

    class WithBboxSpatialQuery(WithDefaultParams):

        def topic(self):
            lat = 0.0
            lon = 0.0
            sfield = "my_field"

# Path: dopplr/solr/query/spatial.py
# class BoundingBoxSpatialQuery(SpatialQuery):
#     """
#     `BoundingBoxSpatialQuery` to search with bbox functionality
#     param lat the latitute point part
#     param lon the lontitude point part
#     param sfield the location type field
#     param distance the radius around the given location
#     """
#     def __init__(self, lat, lon, sfield, distance=5):
#         super(BoundingBoxSpatialQuery, self).__init__(lat, lon, sfield,
#             function_type='bbox', distance=distance)
# 
# Path: dopplr/solr/query/spatial.py
# class GeofiltSpatialQuery(SpatialQuery):
#     """
#     `GeofiltSpatialQuery` to search with geofilt functionality
#     param lat the latitute point part
#     param lon the lontitude point part
#     param sfield the location type field
#     param distance the radius around the given location
#     """
#     def __init__(self, lat, lon, sfield, distance=5):
#         super(GeofiltSpatialQuery, self).__init__(lat, lon, sfield,
#             function_type='geofilt', distance=distance)
# 
# Path: dopplr/solr/query/spatial.py
# class SpatialQuery(BaseQuery):
#     """
#     `SpatialQuery` to search with geolocations
#     param lat the latitute point part
#     param lon the lontitude point part
#     param sfield the location type field
#     param function_type is one of {geofilt, bbox}
#     param distance the radius around the given location
#     """
#     def __init__(self, lat, lon, sfield, function_type='geofilt', distance=5):
#         super(SpatialQuery, self).__init__()
#         self.__lat = lat
#         self.__lon = lon
#         self.__sfield = sfield
#         self.__function_type = function_type
#         self.__distance = distance
# 
#     def get_params(self):
#         params = []
#         params.append(('fq', '{!%s}' % (self.__function_type)))
#         params.append(('sfield', self.__sfield))
#         params.append(('pt', '%s,%s' % (self.__lat, self.__lon)))
#         params.append(('d', self.__distance))
#         return params


# Path: vows/solr/spatial_vows.py
from pyvows import Vows, expect
from dopplr.solr.query import BoundingBoxSpatialQuery
from dopplr.solr.query import GeofiltSpatialQuery
from dopplr.solr.query import SpatialQuery


@Vows.batch
class TheSpatialQuery(Vows.Context):

    class WithDefaultParams(Vows.Context):

        def topic(self):
            lat = 0.0
            lon = 0.0
            sfield = "my_field"
            return SpatialQuery(lat, lon, sfield).get_params()

        def mustIncludeFunctionTypeParameter(self, topic):
            expect(topic).to_include(('fq', '{!geofilt}'))

        def mustIncludeCorrectlyFormattedPoint(self, topic):
            expect(topic).to_include(('pt', '0.0,0.0'))

        def mustIncludeDistanceParameter(self, topic):
            expect(topic).to_include(('d', 5))

        def mustIncludeSpatialFieldParameter(self, topic):
            expect(topic).to_include(('sfield', 'my_field'))

    class WithBboxSpatialQuery(WithDefaultParams):

        def topic(self):
            lat = 0.0
            lon = 0.0
            sfield = "my_field"

            return BoundingBoxSpatialQuery(lat, lon, sfield).get_params()