# Path: tests/factories.py
# class QueryFactory(TagsFactory):
#     class Meta:
#         model = website.models.Query
# 
#     title = "title"
#     description = "description"
#     db = factory.SubFactory(DbFactory)
#     owner = factory.SubFactory(UserFactory)
#     graph_extra = "{}"
#     query_text = "select username, last_login from auth_user"
#     pivot_data = False
#     insert_limit = True
# 
# class QueryDefaultFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = website.models.QueryDefault
#     query = factory.SubFactory(QueryFactory)
#     search_for = "<DEFAULT>"
#     replace_with = ""
#     data_type = 'String'
# 
# class UserFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = User
# 
#     username = factory.Sequence(lambda x: "user{}".format(x))
#     email = factory.Sequence(lambda x: "user{}@example.com".format(x))
#     password = factory.PostGenerationMethodCall('set_password', "password")
# 
# class QueryPrecedentFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = website.models.QueryPrecedent
#     final_query = factory.SubFactory(QueryFactory)
#     preceding_query = factory.SubFactory(QueryFactory)
# 
# Path: tests/functional/testcases.py
# class APITestCase(TestCaseMixin, TransactionTestCase):
# 
#     def login(self):
#         self.client.login(username=self.username, password=self.password)


import json
import datetime
import os
from ..factories import QueryFactory, QueryDefaultFactory, UserFactory, \
    QueryPrecedentFactory
from .testcases import APITestCase
            ],
        })


class QueryParameterTest(QueryAPITestCase):
    def mock_valid_user_and_parameter_query(self):
        create_users()
        user = self.create_user()
        self.login()
        query = QueryFactory(
            query_text="""
                select
                    first_name
                from
                    auth_user
                where
                    date_joined > "<DT>"
                    and first_name = "<NAME>"
                limit
                    1
            """,
            owner=user,
        )
        defaults = []
        defaults.append(QueryDefaultFactory(
            query=query,
            search_for="<DT>",
            replace_with="2014-04-01",
            data_type="Date",
        ))

# Path: tests/factories.py
# class QueryFactory(TagsFactory):
#     class Meta:
#         model = website.models.Query
# 
#     title = "title"
#     description = "description"
#     db = factory.SubFactory(DbFactory)
#     owner = factory.SubFactory(UserFactory)
#     graph_extra = "{}"
#     query_text = "select username, last_login from auth_user"
#     pivot_data = False
#     insert_limit = True
# 
# class QueryDefaultFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = website.models.QueryDefault
#     query = factory.SubFactory(QueryFactory)
#     search_for = "<DEFAULT>"
#     replace_with = ""
#     data_type = 'String'
# 
# class UserFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = User
# 
#     username = factory.Sequence(lambda x: "user{}".format(x))
#     email = factory.Sequence(lambda x: "user{}@example.com".format(x))
#     password = factory.PostGenerationMethodCall('set_password', "password")
# 
# class QueryPrecedentFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = website.models.QueryPrecedent
#     final_query = factory.SubFactory(QueryFactory)
#     preceding_query = factory.SubFactory(QueryFactory)
# 
# Path: tests/functional/testcases.py
# class APITestCase(TestCaseMixin, TransactionTestCase):
# 
#     def login(self):
#         self.client.login(username=self.username, password=self.password)


# Path: tests/functional/test_api.py
import json
import datetime
import os
from ..factories import QueryFactory, QueryDefaultFactory, UserFactory, \
    QueryPrecedentFactory
from .testcases import APITestCase

            ],
        })


class QueryParameterTest(QueryAPITestCase):
    def mock_valid_user_and_parameter_query(self):
        create_users()
        user = self.create_user()
        self.login()
        query = QueryFactory(
            query_text="""
                select
                    first_name
                from
                    auth_user
                where
                    date_joined > "<DT>"
                    and first_name = "<NAME>"
                limit
                    1
            """,
            owner=user,
        )
        defaults = []
        defaults.append(QueryDefaultFactory(
            query=query,
            search_for="<DT>",
            replace_with="2014-04-01",
            data_type="Date",
        ))

        defaults.append(QueryDefaultFactory(