# Path: amgut/test/tornado_test_base.py
# 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):
#             data = urlencode(data)
#         return self.fetch(url, method='POST', body=data, headers=headers)


from unittest import main
from tornado.escape import url_escape
from amgut.connections import ag_data
from amgut.test.tornado_test_base import TestHandlerBase
from amgut import text_locale

    def test_post_correct_pass(self):
        # test a sucessful login, for a handout kit
        self.mock_login('cKxwJ')
        response = self.get('/authed/portal/')
        self.assertEqual(response.code, 200)
        self.assertNotIn(text_locale['handlers']['REGISTER_KIT'],
                         response.body)

        # test a sucessful login, for a non-handout kit
        self.mock_login('wiydx')
        response = self.get('/authed/portal/')
        self.assertEqual(response.code, 200)
        self.assertIn(text_locale['portal.html']['VERIFICATION_HEADER_2'],
                      response.body)

    def test_post_wrong_pass(self):
        # check that invalid kit is reported for non existent skid
        response = self.post('/auth/login/', {'skid': 'wrong',
                                              'passwd': 'test'})
        self.assertIn(text_locale['handlers']['INVALID_KITID'], response.body)
        self.assertEqual(response.code, 200)

        # check that invalid password is reported for wrong password
        response = self.post('/auth/login/', {'skid': 'cKxwJ',
                                              'passwd': 'wrong'})
        self.assertIn(text_locale['handlers']['INVALID_KITID'], response.body)
        self.assertEqual(response.code, 200)



# Path: amgut/test/tornado_test_base.py
# 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):
#             data = urlencode(data)
#         return self.fetch(url, method='POST', body=data, headers=headers)


# Path: amgut/test/test_auth_handlers.py
from unittest import main
from tornado.escape import url_escape
from amgut.connections import ag_data
from amgut.test.tornado_test_base import TestHandlerBase
from amgut import text_locale


    def test_post_correct_pass(self):
        # test a sucessful login, for a handout kit
        self.mock_login('cKxwJ')
        response = self.get('/authed/portal/')
        self.assertEqual(response.code, 200)
        self.assertNotIn(text_locale['handlers']['REGISTER_KIT'],
                         response.body)

        # test a sucessful login, for a non-handout kit
        self.mock_login('wiydx')
        response = self.get('/authed/portal/')
        self.assertEqual(response.code, 200)
        self.assertIn(text_locale['portal.html']['VERIFICATION_HEADER_2'],
                      response.body)

    def test_post_wrong_pass(self):
        # check that invalid kit is reported for non existent skid
        response = self.post('/auth/login/', {'skid': 'wrong',
                                              'passwd': 'test'})
        self.assertIn(text_locale['handlers']['INVALID_KITID'], response.body)
        self.assertEqual(response.code, 200)

        # check that invalid password is reported for wrong password
        response = self.post('/auth/login/', {'skid': 'cKxwJ',
                                              'passwd': 'wrong'})
        self.assertIn(text_locale['handlers']['INVALID_KITID'], response.body)
        self.assertEqual(response.code, 200)



class TestAuthLogoutHandler(TestHandlerBase):