# Path: spillway/viewsets.py
# class GenericGeoViewSet(BaseGeoView,
#                         viewsets.ViewSetMixin,
#                         generics.GenericAPIView):
# class ReadOnlyGeoModelViewSet(mixins.RetrieveModelMixin,
#                               mixins.ListModelMixin,
#                               GenericGeoViewSet):
# class GeoModelViewSet(mixins.CreateModelMixin,
#                       mixins.RetrieveModelMixin,
#                       mixins.UpdateModelMixin,
#                       mixins.DestroyModelMixin,
#                       mixins.ListModelMixin,
#                       GenericGeoViewSet):
# class GenericRasterViewSet(BaseRasterView,
#                            viewsets.ViewSetMixin,
#                            generics.GenericAPIView):
# class ReadOnlyRasterModelViewSet(mixins.RetrieveModelMixin,
#                                  mixins.ListModelMixin,
#                                  GenericRasterViewSet):
# 
# Path: spillway/renderers/renderers.py
# class GeoJSONRenderer(JSONRenderer):
#     """Renderer which serializes to GeoJSON.
# 
#     This renderer purposefully avoids reserialization of GeoJSON from the
#     spatial backend which greatly improves performance.
#     """
#     media_type = 'application/vnd.geo+json'
#     format = 'geojson'
#     charset = 'utf-8'
# 
#     def render(self, data, accepted_media_type=None, renderer_context=None):
#         """Returns *data* encoded as GeoJSON."""
#         data = collections.as_feature(data)
#         try:
#             return data.geojson
#         except AttributeError:
#             return super(GeoJSONRenderer, self).render(
#                 data, accepted_media_type, renderer_context)
# 
# Path: spillway/renderers/gdal.py
# class GeoTIFFZipRenderer(BaseGDALRenderer):
#     """Bundles GeoTIFF rasters in a zip archive."""
#     media_type = 'application/zip'
#     format = 'tif.zip'
#     arcdirname = 'data'
# 
#     def render(self, data, accepted_media_type=None, renderer_context=None):
#         if len(data) > 1:
#             raise ValueError('Expected one-length sequence')
#         return super(GeoTIFFZipRenderer, self).render(
#             data[0], accepted_media_type, renderer_context)
# 
# Path: tests/models.py
# class GeoLocation(AbstractLocation):
#     """Test geo location."""
# 
# class Location(AbstractLocation):
#     """Test location."""
#     objects = GeoQuerySet.as_manager()
# 
# class RasterStore(AbstractRasterStore):
#     objects = RasterQuerySet.as_manager()
# 
# Path: tests/test_serializers.py
# class LocationFeatureSerializer(serializers.FeatureSerializer):
#     class Meta:
#         model = Location
#         fields = '__all__'
#         geom_field = 'geom'
# 
# class RasterStoreSerializer(serializers.RasterModelSerializer):
#     class Meta:
#         model = RasterStore
#         fields = '__all__'


from django.test import SimpleTestCase
from rest_framework.routers import DefaultRouter
from rest_framework.test import APIRequestFactory
from spillway import viewsets
from spillway.renderers import GeoJSONRenderer, GeoTIFFZipRenderer
from .models import GeoLocation, Location, RasterStore
from .test_serializers import LocationFeatureSerializer, RasterStoreSerializer
    serializer_class = RasterStoreSerializer


class GeoModelViewSetTestCase(SimpleQueryTestCase):
    def setUp(self):
        self.router = DefaultRouter()
        self.router.register(r'locations', LocationViewSet)
        self.view = LocationViewSet.as_view({'get': 'list'})

    def test_renderer(self):
        request = factory.get('/locations/',
                              HTTP_ACCEPT=GeoJSONRenderer.media_type)
        response = self.view(request)
        self.assertIsInstance(response.accepted_renderer, GeoJSONRenderer)

    def test_register(self):
        self.assertGreater(len(self.router.urls), 0)


class RasterViewSetTestCase(SimpleQueryTestCase):
    def setUp(self):
        self.router = DefaultRouter()
        self.router.register(r'rasters', RasterViewSet)
        self.view = RasterViewSet.as_view({'get': 'list'})

    def test_renderer(self):
        request = factory.get('/rasters/',
                              HTTP_ACCEPT=GeoTIFFZipRenderer.media_type)
        response = self.view(request)
        self.assertEqual(response['Content-Type'],

# Path: spillway/viewsets.py
# class GenericGeoViewSet(BaseGeoView,
#                         viewsets.ViewSetMixin,
#                         generics.GenericAPIView):
# class ReadOnlyGeoModelViewSet(mixins.RetrieveModelMixin,
#                               mixins.ListModelMixin,
#                               GenericGeoViewSet):
# class GeoModelViewSet(mixins.CreateModelMixin,
#                       mixins.RetrieveModelMixin,
#                       mixins.UpdateModelMixin,
#                       mixins.DestroyModelMixin,
#                       mixins.ListModelMixin,
#                       GenericGeoViewSet):
# class GenericRasterViewSet(BaseRasterView,
#                            viewsets.ViewSetMixin,
#                            generics.GenericAPIView):
# class ReadOnlyRasterModelViewSet(mixins.RetrieveModelMixin,
#                                  mixins.ListModelMixin,
#                                  GenericRasterViewSet):
# 
# Path: spillway/renderers/renderers.py
# class GeoJSONRenderer(JSONRenderer):
#     """Renderer which serializes to GeoJSON.
# 
#     This renderer purposefully avoids reserialization of GeoJSON from the
#     spatial backend which greatly improves performance.
#     """
#     media_type = 'application/vnd.geo+json'
#     format = 'geojson'
#     charset = 'utf-8'
# 
#     def render(self, data, accepted_media_type=None, renderer_context=None):
#         """Returns *data* encoded as GeoJSON."""
#         data = collections.as_feature(data)
#         try:
#             return data.geojson
#         except AttributeError:
#             return super(GeoJSONRenderer, self).render(
#                 data, accepted_media_type, renderer_context)
# 
# Path: spillway/renderers/gdal.py
# class GeoTIFFZipRenderer(BaseGDALRenderer):
#     """Bundles GeoTIFF rasters in a zip archive."""
#     media_type = 'application/zip'
#     format = 'tif.zip'
#     arcdirname = 'data'
# 
#     def render(self, data, accepted_media_type=None, renderer_context=None):
#         if len(data) > 1:
#             raise ValueError('Expected one-length sequence')
#         return super(GeoTIFFZipRenderer, self).render(
#             data[0], accepted_media_type, renderer_context)
# 
# Path: tests/models.py
# class GeoLocation(AbstractLocation):
#     """Test geo location."""
# 
# class Location(AbstractLocation):
#     """Test location."""
#     objects = GeoQuerySet.as_manager()
# 
# class RasterStore(AbstractRasterStore):
#     objects = RasterQuerySet.as_manager()
# 
# Path: tests/test_serializers.py
# class LocationFeatureSerializer(serializers.FeatureSerializer):
#     class Meta:
#         model = Location
#         fields = '__all__'
#         geom_field = 'geom'
# 
# class RasterStoreSerializer(serializers.RasterModelSerializer):
#     class Meta:
#         model = RasterStore
#         fields = '__all__'


# Path: tests/test_viewsets.py
from django.test import SimpleTestCase
from rest_framework.routers import DefaultRouter
from rest_framework.test import APIRequestFactory
from spillway import viewsets
from spillway.renderers import GeoJSONRenderer, GeoTIFFZipRenderer
from .models import GeoLocation, Location, RasterStore
from .test_serializers import LocationFeatureSerializer, RasterStoreSerializer

    serializer_class = RasterStoreSerializer


class GeoModelViewSetTestCase(SimpleQueryTestCase):
    def setUp(self):
        self.router = DefaultRouter()
        self.router.register(r'locations', LocationViewSet)
        self.view = LocationViewSet.as_view({'get': 'list'})

    def test_renderer(self):
        request = factory.get('/locations/',
                              HTTP_ACCEPT=GeoJSONRenderer.media_type)
        response = self.view(request)
        self.assertIsInstance(response.accepted_renderer, GeoJSONRenderer)

    def test_register(self):
        self.assertGreater(len(self.router.urls), 0)


class RasterViewSetTestCase(SimpleQueryTestCase):
    def setUp(self):
        self.router = DefaultRouter()
        self.router.register(r'rasters', RasterViewSet)
        self.view = RasterViewSet.as_view({'get': 'list'})

    def test_renderer(self):
        request = factory.get('/rasters/',
                              HTTP_ACCEPT=GeoTIFFZipRenderer.media_type)
        response = self.view(request)
        self.assertEqual(response['Content-Type'],

                         GeoTIFFZipRenderer.media_type)