import json

from rest_framework.test import APIClient
from rest_framework import status
from rest_framework.test import APITestCase


class TestResourceTypes(APITestCase):

    def setUp(self):
        self.client = APIClient()

        # Use a static list so that this test breaks when a resource type is
        # added or removed (so that the test can be updated)
        self.resource_types = {'GenericResource',
                               'RasterResource',
                               'RefTimeSeriesResource',
                               'TimeSeriesResource',
                               'NetcdfResource',
                               'ModelProgramResource',
                               'ModelInstanceResource',
                               'ToolResource',
                               'SWATModelInstanceResource',
                               'GeographicFeatureResource',
                               'ScriptResource',
                               'CollectionResource',
                               'MODFLOWModelInstanceResource'}

    def test_DEPRECATED_resource_typelist(self):
        response = self.client.get('/hsapi/resourceTypes/', format='json')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        content = json.loads(response.content)
        rest_resource_types = set([t['resource_type'] for t in content])

        self.assertEqual(self.resource_types, rest_resource_types)

    def test_resource_typelist(self):
        response = self.client.get('/hsapi/resource/types/', format='json')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        content = json.loads(response.content)
        rest_resource_types = set([t['resource_type'] for t in content])

        self.assertEqual(self.resource_types, rest_resource_types)

@@ -1059,16 +1059,68 @@
 esource'
+,%0A                               'CompositeResource'
 %7D%0A%0A    d

fix for broken unit test in hs_core