<s> from django . test import TestCase <EOL> from rest_framework import exceptions <EOL> from rest_framework . test import APIRequestFactory <EOL> from spillway import generics , filters <EOL> from . models import Location <EOL> factory = APIRequestFactory ( ) <EOL> class FilterTestCase ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . filter = filters . SpatialLookupFilter ( ) <EOL> self . view = generics . GeoListView . as_view ( <EOL> queryset = Location . objects . all ( ) ) <EOL> Location . create ( ) <EOL> self . centroid = Location . objects . centroid ( ) [ <NUM_LIT:0> ] . centroid <EOL> self . queryset = Location . objects . all ( ) <EOL> def test_spatial_lookup ( self ) : <EOL> request = factory . get ( '<STR_LIT:/>' , { '<STR_LIT>' : self . centroid . wkt } ) <EOL> ctx = self . view ( request ) . renderer_context <EOL> qcontain = self . filter . filter_queryset ( ctx [ '<STR_LIT>' ] , <EOL> self . queryset , self . view ) <EOL> self . assertQuerysetEqual ( qcontain , map ( repr , self . queryset ) ) <EOL> def test_invalid_value ( self ) : <EOL> request = factory . get ( '<STR_LIT:/>' , { '<STR_LIT>' : <NUM_LIT:2> } ) <EOL> ctx = self . view ( request ) . renderer_context <EOL> self . assertRaises ( exceptions . ParseError , self . filter . filter_queryset , <EOL> ctx [ '<STR_LIT>' ] , self . queryset , self . view ) </s>
