# Path: pyvac/tests/case.py
# class ModelTestCase(TestCase):
# class DummyRoute(object):
# class DummyRequest(testing.DummyRequest):
# class UnauthenticatedViewTestCase(TestCase):
# class ViewTestCase(UnauthenticatedViewTestCase):
# class ViewAdminTestCase(ViewTestCase):
#     def setUp(self):
#     def tearDown(self):
#     def auto_translate(string, country):
#     def __init__(self, methodName='runTest'):
#     def setUp(self):
#     def tearDown(self):
#     def create_request(self, params=None, environ=None, matchdict=None,
#                        headers=None, path='/', cookies=None, post=None, **kw):
#     def assertIsRedirect(self, view):
#     def setUp(self):
#     def set_userid(self, userid='admin', permissive=False):
#     def setUp(self):


from pyvac.tests import case
        from pyvac.views.user import Edit
        from pyvac.views.user import ChangePassword as ChangePwd
        from pyvac.models import User
        from pyvac.views.user import Edit
        from pyvac.models import User
        from pyvac.views.user import ChangePassword as ChangePwd
        from pyvac.models import User
        from pyvac.views.user import ChangePassword as ChangePwd
        from pyvac.models import User
        from pyvac.views.user import ChangePassword as ChangePwd
        self.assertIsInstance(admin, User)
        self.assertEqual(admin.login, 'root')
        self.assertEqual(admin.firstname, 'Admin')
        self.assertEqual(admin.lastname, 'Istrator')
        admin.login = 'admin'
        admin.password = 'changeme'
        admin.firstname = None
        admin.lastname = None
        self.session.add(admin)

    def test_change_password_post_ok(self):
        ChangePwd(self.create_request({'form.submitted': '1',
                                       'current_password': 'changeme',
                                       'user.password': 'newpassw',
                                       'confirm_password': 'newpassw',
                                       }))()
        admin = User.by_credentials(self.session, 'admin', 'newpassw')
        self.assertIsInstance(admin, User)
        admin.password = 'changeme'
        self.session.add(admin)

    def test_change_password_post_ko_not_matched(self):
        view = ChangePwd(self.create_request({'form.submitted': '1',
                                              'current_password': 'CHANGEME',
                                              'user.password': 'newpassw',
                                              'confirm_password': 'NEWPASSW',
                                              }))()
        self.assertEqual(view['errors'],
                         ['current password is not correct',
                          'passwords do not match'])

# Path: pyvac/tests/case.py
# class ModelTestCase(TestCase):
# class DummyRoute(object):
# class DummyRequest(testing.DummyRequest):
# class UnauthenticatedViewTestCase(TestCase):
# class ViewTestCase(UnauthenticatedViewTestCase):
# class ViewAdminTestCase(ViewTestCase):
#     def setUp(self):
#     def tearDown(self):
#     def auto_translate(string, country):
#     def __init__(self, methodName='runTest'):
#     def setUp(self):
#     def tearDown(self):
#     def create_request(self, params=None, environ=None, matchdict=None,
#                        headers=None, path='/', cookies=None, post=None, **kw):
#     def assertIsRedirect(self, view):
#     def setUp(self):
#     def set_userid(self, userid='admin', permissive=False):
#     def setUp(self):


# Path: pyvac/tests/views/test_user.py
from pyvac.tests import case
        from pyvac.views.user import Edit
        from pyvac.views.user import ChangePassword as ChangePwd
        from pyvac.models import User
        from pyvac.views.user import Edit
        from pyvac.models import User
        from pyvac.views.user import ChangePassword as ChangePwd
        from pyvac.models import User
        from pyvac.views.user import ChangePassword as ChangePwd
        from pyvac.models import User
        from pyvac.views.user import ChangePassword as ChangePwd

        self.assertIsInstance(admin, User)
        self.assertEqual(admin.login, 'root')
        self.assertEqual(admin.firstname, 'Admin')
        self.assertEqual(admin.lastname, 'Istrator')
        admin.login = 'admin'
        admin.password = 'changeme'
        admin.firstname = None
        admin.lastname = None
        self.session.add(admin)

    def test_change_password_post_ok(self):
        ChangePwd(self.create_request({'form.submitted': '1',
                                       'current_password': 'changeme',
                                       'user.password': 'newpassw',
                                       'confirm_password': 'newpassw',
                                       }))()
        admin = User.by_credentials(self.session, 'admin', 'newpassw')
        self.assertIsInstance(admin, User)
        admin.password = 'changeme'
        self.session.add(admin)

    def test_change_password_post_ko_not_matched(self):
        view = ChangePwd(self.create_request({'form.submitted': '1',
                                              'current_password': 'CHANGEME',
                                              'user.password': 'newpassw',
                                              'confirm_password': 'NEWPASSW',
                                              }))()
        self.assertEqual(view['errors'],
                         ['current password is not correct',
                          'passwords do not match'])

        admin = User.by_credentials(self.session, 'admin', 'changeme')