# Path: tests/cases/resources/tests/base.py
# class AuthenticatedBaseTestCase(BaseTestCase):
#     def setUp(self):
#         super(AuthenticatedBaseTestCase, self).setUp()
# 
#         self.user = User.objects.create_user(username='test', password='test')
#         self.client.login(username='test', password='test')


import json
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.test import Client
from restlib2.http import codes
from avocado.history.models import Revision
from avocado.models import DataView
from .base import AuthenticatedBaseTestCase
        from django.conf import settings
        from django.utils.importlib import import_module
    def test_delete(self):
        view1 = DataView(user=self.user, name='View 1')
        view1.save()
        view2 = DataView(user=self.user, name='View 2')
        view2.save()
        view3 = DataView(user=self.user, name='View 3', session=True)
        view3.save()

        response = self.client.get('/api/views/',
                                   HTTP_ACCEPT='application/json')
        self.assertEqual(response.status_code, codes.ok)
        self.assertEqual(len(json.loads(response.content)), 3)

        response = self.client.delete('/api/views/{0}/'.format(view1.pk))
        self.assertEqual(response.status_code, codes.no_content)

        response = self.client.get('/api/views/',
                                   HTTP_ACCEPT='application/json')
        self.assertEqual(response.status_code, codes.ok)
        self.assertEqual(len(json.loads(response.content)), 2)

        response = self.client.delete('/api/views/{0}/'.format(view3.pk))
        self.assertEqual(response.status_code, codes.bad_request)

        response = self.client.get('/api/views/',
                                   HTTP_ACCEPT='application/json')
        self.assertEqual(response.status_code, codes.ok)
        self.assertEqual(len(json.loads(response.content)), 2)



# Path: tests/cases/resources/tests/base.py
# class AuthenticatedBaseTestCase(BaseTestCase):
#     def setUp(self):
#         super(AuthenticatedBaseTestCase, self).setUp()
# 
#         self.user = User.objects.create_user(username='test', password='test')
#         self.client.login(username='test', password='test')


# Path: tests/cases/resources/tests/view.py
import json
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.test import Client
from restlib2.http import codes
from avocado.history.models import Revision
from avocado.models import DataView
from .base import AuthenticatedBaseTestCase
        from django.conf import settings
        from django.utils.importlib import import_module

    def test_delete(self):
        view1 = DataView(user=self.user, name='View 1')
        view1.save()
        view2 = DataView(user=self.user, name='View 2')
        view2.save()
        view3 = DataView(user=self.user, name='View 3', session=True)
        view3.save()

        response = self.client.get('/api/views/',
                                   HTTP_ACCEPT='application/json')
        self.assertEqual(response.status_code, codes.ok)
        self.assertEqual(len(json.loads(response.content)), 3)

        response = self.client.delete('/api/views/{0}/'.format(view1.pk))
        self.assertEqual(response.status_code, codes.no_content)

        response = self.client.get('/api/views/',
                                   HTTP_ACCEPT='application/json')
        self.assertEqual(response.status_code, codes.ok)
        self.assertEqual(len(json.loads(response.content)), 2)

        response = self.client.delete('/api/views/{0}/'.format(view3.pk))
        self.assertEqual(response.status_code, codes.bad_request)

        response = self.client.get('/api/views/',
                                   HTTP_ACCEPT='application/json')
        self.assertEqual(response.status_code, codes.ok)
        self.assertEqual(len(json.loads(response.content)), 2)



class ViewsRevisionsResourceTestCase(AuthenticatedBaseTestCase):