# 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

    def test_session(self):
        query = DataQuery(session=True, user=self.user)
        query.save()

        response = self.client.get('/api/queries/session/stats/',
                                   HTTP_ACCEPT='application/json')

        data = json.loads(response.content)
        self.assertEqual(data['distinct_count'], 6)
        self.assertEqual(data['record_count'], 6)

    def test_processor(self):
        query = DataQuery(session=True, user=self.user)
        query.save()

        response = self.client.get('/api/queries/{0}/stats/'.format(query.pk),
                                   HTTP_ACCEPT='application/json')
        data = json.loads(response.content)
        self.assertEqual(data['distinct_count'], 6)
        self.assertEqual(data['record_count'], 6)

        response = self.client.get('/api/queries/{0}/stats/?processor=manager'
                                   .format(query.pk),
                                   HTTP_ACCEPT='application/json')
        data = json.loads(response.content)
        self.assertEqual(data['distinct_count'], 1)
        self.assertEqual(data['record_count'], 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


    def test_session(self):
        query = DataQuery(session=True, user=self.user)
        query.save()

        response = self.client.get('/api/queries/session/stats/',
                                   HTTP_ACCEPT='application/json')

        data = json.loads(response.content)
        self.assertEqual(data['distinct_count'], 6)
        self.assertEqual(data['record_count'], 6)

    def test_processor(self):
        query = DataQuery(session=True, user=self.user)
        query.save()

        response = self.client.get('/api/queries/{0}/stats/'.format(query.pk),
                                   HTTP_ACCEPT='application/json')
        data = json.loads(response.content)
        self.assertEqual(data['distinct_count'], 6)
        self.assertEqual(data['record_count'], 6)

        response = self.client.get('/api/queries/{0}/stats/?processor=manager'
                                   .format(query.pk),
                                   HTTP_ACCEPT='application/json')
        data = json.loads(response.content)
        self.assertEqual(data['distinct_count'], 1)
        self.assertEqual(data['record_count'], 1)



class EmailTestCase(BaseTestCase):