# 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')
# 
# class BaseTestCase(TestCase):
#     fixtures = ['tests/fixtures/test_data.json']
# 
#     def setUp(self):
#         management.call_command('avocado', 'init', 'tests', quiet=True,
#                                 publish=False, concepts=False)
#         DataField.objects.filter(
#             model_name__in=['project', 'title']).update(published=True)
# 
#         self.user = User.objects.create_user(username='root',
#                                              password='password')
#         self.user.is_superuser = True
#         self.user.save()


import json
import time
from django.contrib.auth.models import User
from django.core import mail
from restlib2.http import codes
from avocado.models import DataQuery
from .base import AuthenticatedBaseTestCase, BaseTestCase
        from serrano.utils import send_mail
        from serrano.utils import send_mail
                     email='')
        user3 = User(username='u3', first_name='Shared', last_name='User',
                     email='share3@example.com')

        send_mail([user1.email, user2.email, user3.email], self.subject,
                  self.message)

        # Make sure the mail was sent(after a slight pause to account for the
        # "asynchronousness".
        time.sleep(5)
        self.assertEqual(len(mail.outbox), 1)
        # Make sure the subject is correct
        self.assertEqual(mail.outbox[0].subject, self.subject)
        self.assertEqual(mail.outbox[0].body, self.message)
        # Make sure the recipient list is correct
        self.assertSequenceEqual(
            mail.outbox[0].to, ['share@example.com', '', 'share3@example.com'])


class QueriesRevisionsResourceTestCase(AuthenticatedBaseTestCase):
    def test_get(self):
        query = DataQuery(user=self.user)
        query.save()

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



# 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')
# 
# class BaseTestCase(TestCase):
#     fixtures = ['tests/fixtures/test_data.json']
# 
#     def setUp(self):
#         management.call_command('avocado', 'init', 'tests', quiet=True,
#                                 publish=False, concepts=False)
#         DataField.objects.filter(
#             model_name__in=['project', 'title']).update(published=True)
# 
#         self.user = User.objects.create_user(username='root',
#                                              password='password')
#         self.user.is_superuser = True
#         self.user.save()


# Path: tests/cases/resources/tests/query.py
import json
import time
from django.contrib.auth.models import User
from django.core import mail
from restlib2.http import codes
from avocado.models import DataQuery
from .base import AuthenticatedBaseTestCase, BaseTestCase
        from serrano.utils import send_mail
        from serrano.utils import send_mail

                     email='')
        user3 = User(username='u3', first_name='Shared', last_name='User',
                     email='share3@example.com')

        send_mail([user1.email, user2.email, user3.email], self.subject,
                  self.message)

        # Make sure the mail was sent(after a slight pause to account for the
        # "asynchronousness".
        time.sleep(5)
        self.assertEqual(len(mail.outbox), 1)
        # Make sure the subject is correct
        self.assertEqual(mail.outbox[0].subject, self.subject)
        self.assertEqual(mail.outbox[0].body, self.message)
        # Make sure the recipient list is correct
        self.assertSequenceEqual(
            mail.outbox[0].to, ['share@example.com', '', 'share3@example.com'])


class QueriesRevisionsResourceTestCase(AuthenticatedBaseTestCase):
    def test_get(self):
        query = DataQuery(user=self.user)
        query.save()

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



class QueryResultsResourceTestCase(AuthenticatedBaseTestCase):