# Path: spillway/filters.py
# class FormFilterBackend(BaseFilterBackend):
# class GeoQuerySetFilter(FormFilterBackend):
# class RasterQuerySetFilter(FormFilterBackend):
# class SpatialLookupFilter(FormFilterBackend):
# class TileFilter(FormFilterBackend):
#     def filter_queryset(self, request, queryset, view):
# 
# Path: tests/models.py
# class Location(AbstractLocation):
#     """Test location."""
#     objects = GeoQuerySet.as_manager()


from django.test import TestCase
from rest_framework import serializers
from spillway import filters
from .models import Location



class FilterTestCase(TestCase):
    def setUp(self):
        self.filter = filters.SpatialLookupFilter()
        Location.create()
        self.queryset = Location.objects.all()

    def test_spatial_lookup(self):
        centroid = self.queryset[0].geom.centroid
        response = self.client.get('/locations/', {'contains': centroid.wkt})
        req = response.renderer_context['request']
        view = response.renderer_context['view']
        qcontain = self.filter.filter_queryset(req, self.queryset, view)
        self.assertQuerysetEqual(qcontain, map(repr, self.queryset))

    def test_invalid_value(self):

# Path: spillway/filters.py
# class FormFilterBackend(BaseFilterBackend):
# class GeoQuerySetFilter(FormFilterBackend):
# class RasterQuerySetFilter(FormFilterBackend):
# class SpatialLookupFilter(FormFilterBackend):
# class TileFilter(FormFilterBackend):
#     def filter_queryset(self, request, queryset, view):
# 
# Path: tests/models.py
# class Location(AbstractLocation):
#     """Test location."""
#     objects = GeoQuerySet.as_manager()


# Path: tests/test_filters.py
from django.test import TestCase
from rest_framework import serializers
from spillway import filters
from .models import Location




class FilterTestCase(TestCase):
    def setUp(self):
        self.filter = filters.SpatialLookupFilter()
        Location.create()
        self.queryset = Location.objects.all()

    def test_spatial_lookup(self):
        centroid = self.queryset[0].geom.centroid
        response = self.client.get('/locations/', {'contains': centroid.wkt})
        req = response.renderer_context['request']
        view = response.renderer_context['view']
        qcontain = self.filter.filter_queryset(req, self.queryset, view)
        self.assertQuerysetEqual(qcontain, map(repr, self.queryset))

    def test_invalid_value(self):

        response = self.client.get('/locations/', {'contains': 2})