# Path: amgut/webserver.py
# class AGWebApplication(Application):
#     def __init__(self):
#         handlers = [
#             (r"/static/(.*)", BaseStaticFileHandler, {"path": STATIC_PATH}),
#             (r"/", MainHandler),
#             (r"/db_error/", DBErrorHandler),
#             (r"/auth/login/", AuthLoginHandler),
#             (r"/auth/logout/", AuthLogoutHandler),
#             (r"/auth/register/", AuthRegisterHandoutHandler),
#             (r"/authed/help_request/", HelpRequestHandler),
#             (r"/authed/addendum/", AddendumHandler),
#             (r"/authed/new_participant/", NewParticipantHandler),
#             (r"/authed/new_participant_overview/",
#              NewParticipantOverviewHandler),
#             (r"/authed/sample_overview/", SampleOverviewHandler),
#             (r"/authed/add_sample_overview/", AddSampleOverviewHandler),
#             (r"/authed/survey_main/", SurveyMainHandler),
#             (r"/authed/human_survey/", HumanSurveyHandler),
#             (r"/authed/human_survey_completed/", HumanSurveyCompletedHandler),
#             (r"/authed/vspassthrough/", VioscreenPassthroughHandler),
#             (r"/authed/secondary_survey/", SecondarySurveyHandler),
#             (r"/authed/personal_microbiome_overview/",
#              PersonalMicrobiomeOverviewHandler),
#             (r"/authed/portal/", PortalHandler),
#             (r"/authed/add_sample_human/", AddHumanSampleHandler),
#             (r"/authed/add_sample_human_ffq/", AddHumanFFQHandler),
#             (r"/authed/add_sample_animal/", AddAnimalSampleHandler),
#             (r"/authed/add_sample_general/", AddGeneralSampleHandler),
#             (r"/authed/change_password/", ChangePasswordHandler),
#             (r"/authed/add_animal/", AnimalSurveyHandler),
#             (r"/authed/open-humans/", OpenHumansHandler),
#             (r"/authed/connect/open-humans/", OpenHumansLoginHandler),
#             (r"/authed/download/(.*)", DownloadHandler),
#             (r"/faq/", FAQHandler),
#             (r"/introduction/", IntroductionHandler),
#             (r"/participants/(.*)", ParticipantOverviewHandler),
#             (r"/international_shipping/", InternationalHandler),
#             (r"/check_participant_name/", CheckParticipantName),
#             (r"/authed/taxa_summaries/(.*)", TaxaSummaryHandler),
#             (r"/authed/basic_report/(.*)", BasicReportHandler),
#             (r"/authed/interactive_report/(.*)", InteractiveReportHandler),
#             (r"/retrieve_kitid/", KitIDHandler),
#             (r"/forgot_password/", ForgotPasswordHandler),
#             (r"/change_pass_verify/", ChangePassVerifyHandler),
#             (r"/nojs/", NoJSHandler),
#             # 404 PAGE MUST BE LAST IN THIS LIST!
#             (r".*", NoPageHandler)
#         ]
#         settings = {
#             "template_path": TEMPLATE_PATH,
#             "debug": DEBUG,
#             "cookie_secret": AMGUT_CONFIG.cookie_secret,
#             # Currently the only login form is on the homepage
#             "login_url": media_locale['SITEBASE'] + '/',
#         }
#         super(AGWebApplication, self).__init__(handlers, **settings)


from mock import Mock
    from urllib import urlencode
    from urllib.parse import urlencode
from tornado.testing import AsyncHTTPTestCase, LogTrapTestCase
from amgut.webserver import AGWebApplication
from amgut.handlers.base_handlers import BaseHandler
try:
except ImportError:  # py3



class TestHandlerBase(AsyncHTTPTestCase, LogTrapTestCase):
    orig_func = BaseHandler.get_current_user

    def tearDown(self):
        BaseHandler.get_current_user = self.orig_func
        super(TestHandlerBase, self).tearDown()

    def get_app(self):
        self.app = AGWebApplication()
        return self.app

    def mock_login(self, user):
        BaseHandler.get_current_user = Mock(return_value=user)

    def get(self, url, data=None, headers=None):
        if isinstance(data, dict):
            data = urlencode(data)
        return self.fetch(url, method='GET', body=data, headers=headers)

    def post(self, url, data, headers=None):

# Path: amgut/webserver.py
# class AGWebApplication(Application):
#     def __init__(self):
#         handlers = [
#             (r"/static/(.*)", BaseStaticFileHandler, {"path": STATIC_PATH}),
#             (r"/", MainHandler),
#             (r"/db_error/", DBErrorHandler),
#             (r"/auth/login/", AuthLoginHandler),
#             (r"/auth/logout/", AuthLogoutHandler),
#             (r"/auth/register/", AuthRegisterHandoutHandler),
#             (r"/authed/help_request/", HelpRequestHandler),
#             (r"/authed/addendum/", AddendumHandler),
#             (r"/authed/new_participant/", NewParticipantHandler),
#             (r"/authed/new_participant_overview/",
#              NewParticipantOverviewHandler),
#             (r"/authed/sample_overview/", SampleOverviewHandler),
#             (r"/authed/add_sample_overview/", AddSampleOverviewHandler),
#             (r"/authed/survey_main/", SurveyMainHandler),
#             (r"/authed/human_survey/", HumanSurveyHandler),
#             (r"/authed/human_survey_completed/", HumanSurveyCompletedHandler),
#             (r"/authed/vspassthrough/", VioscreenPassthroughHandler),
#             (r"/authed/secondary_survey/", SecondarySurveyHandler),
#             (r"/authed/personal_microbiome_overview/",
#              PersonalMicrobiomeOverviewHandler),
#             (r"/authed/portal/", PortalHandler),
#             (r"/authed/add_sample_human/", AddHumanSampleHandler),
#             (r"/authed/add_sample_human_ffq/", AddHumanFFQHandler),
#             (r"/authed/add_sample_animal/", AddAnimalSampleHandler),
#             (r"/authed/add_sample_general/", AddGeneralSampleHandler),
#             (r"/authed/change_password/", ChangePasswordHandler),
#             (r"/authed/add_animal/", AnimalSurveyHandler),
#             (r"/authed/open-humans/", OpenHumansHandler),
#             (r"/authed/connect/open-humans/", OpenHumansLoginHandler),
#             (r"/authed/download/(.*)", DownloadHandler),
#             (r"/faq/", FAQHandler),
#             (r"/introduction/", IntroductionHandler),
#             (r"/participants/(.*)", ParticipantOverviewHandler),
#             (r"/international_shipping/", InternationalHandler),
#             (r"/check_participant_name/", CheckParticipantName),
#             (r"/authed/taxa_summaries/(.*)", TaxaSummaryHandler),
#             (r"/authed/basic_report/(.*)", BasicReportHandler),
#             (r"/authed/interactive_report/(.*)", InteractiveReportHandler),
#             (r"/retrieve_kitid/", KitIDHandler),
#             (r"/forgot_password/", ForgotPasswordHandler),
#             (r"/change_pass_verify/", ChangePassVerifyHandler),
#             (r"/nojs/", NoJSHandler),
#             # 404 PAGE MUST BE LAST IN THIS LIST!
#             (r".*", NoPageHandler)
#         ]
#         settings = {
#             "template_path": TEMPLATE_PATH,
#             "debug": DEBUG,
#             "cookie_secret": AMGUT_CONFIG.cookie_secret,
#             # Currently the only login form is on the homepage
#             "login_url": media_locale['SITEBASE'] + '/',
#         }
#         super(AGWebApplication, self).__init__(handlers, **settings)


# Path: amgut/test/tornado_test_base.py
from mock import Mock
    from urllib import urlencode
    from urllib.parse import urlencode
from tornado.testing import AsyncHTTPTestCase, LogTrapTestCase
from amgut.webserver import AGWebApplication
from amgut.handlers.base_handlers import BaseHandler

try:
except ImportError:  # py3



class TestHandlerBase(AsyncHTTPTestCase, LogTrapTestCase):
    orig_func = BaseHandler.get_current_user

    def tearDown(self):
        BaseHandler.get_current_user = self.orig_func
        super(TestHandlerBase, self).tearDown()

    def get_app(self):
        self.app = AGWebApplication()
        return self.app

    def mock_login(self, user):
        BaseHandler.get_current_user = Mock(return_value=user)

    def get(self, url, data=None, headers=None):
        if isinstance(data, dict):
            data = urlencode(data)
        return self.fetch(url, method='GET', body=data, headers=headers)

    def post(self, url, data, headers=None):

        if isinstance(data, dict):