# 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 datetime import datetime
from freezegun import freeze_time
from pyvac.tests import case
from pyvac.tests.mocks.tasks import DummyTasks
from pyvac.tests.mocks.celery import subtask
from mock import patch, MagicMock, PropertyMock
from dateutil.relativedelta import relativedelta
        from pyvac.models import Request
        from pyvac.views.request import List
        from pyvac.models import Request
        from pyvac.views.request import List
        from pyvac.models import Request
        from pyvac.views.request import List
        from pyvac.models import Request
        from pyvac.views.request import List
        from pyvac.models import Request
        from pyvac.views.request import Accept
        from pyvac.models import Request
        from pyvac.views.request import Accept
        from pyvac.models import Request
        from pyvac.views.request import Refuse
        from pyvac.models import Request
        from pyvac.views.request import Refuse
        from pyvac.models import Request
        from pyvac.views.request import Refuse
        from pyvac.models import Request
        from pyvac.views.request import Cancel
        from pyvac.models import Request
        from pyvac.views.request import Cancel
        from pyvac.models import Request
        from pyvac.views.request import Cancel
        from pyvac.models import Request
        from pyvac.views.request import Cancel
        from pyvac.views.request import Export
        from pyvac.views.request import Exported
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request, User, CPVacation
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        total_req = Request.find(self.session, count=True)
        view = Send(self.create_request({
            'days': 0.5,
            'date_from': '05/05/2015 - 05/05/2015',
            'type': '1',
            'breakdown': 'AM',
        }))()
        self.assertIsRedirect(view)
        self.assertEqual(Request.find(self.session, count=True), total_req + 1)

    def test_post_send_half_day_ko(self):
        self.config.testing_securitypolicy(userid='jdoe',
                                           permissive=True)
        total_req = Request.find(self.session, count=True)

        with freeze_time('2011-07-14',
                         ignore=['celery', 'psycopg2', 'sqlalchemy',
                                 'icalendar']):
            request = self.create_request({
                'days': 0.5,
                'date_from': '24/08/2011 - 24/08/2011',
                'type': '1',
                'breakdown': 'AM',
            })
            view = Send(request)()
        self.assertIsRedirect(view)
        expected = ['error;Invalid period: days already requested.']
        self.assertEqual(request.session.pop_flash(), expected)
        self.assertEqual(Request.find(self.session, count=True), total_req)


# 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_request.py
from datetime import datetime
from freezegun import freeze_time
from pyvac.tests import case
from pyvac.tests.mocks.tasks import DummyTasks
from pyvac.tests.mocks.celery import subtask
from mock import patch, MagicMock, PropertyMock
from dateutil.relativedelta import relativedelta
        from pyvac.models import Request
        from pyvac.views.request import List
        from pyvac.models import Request
        from pyvac.views.request import List
        from pyvac.models import Request
        from pyvac.views.request import List
        from pyvac.models import Request
        from pyvac.views.request import List
        from pyvac.models import Request
        from pyvac.views.request import Accept
        from pyvac.models import Request
        from pyvac.views.request import Accept
        from pyvac.models import Request
        from pyvac.views.request import Refuse
        from pyvac.models import Request
        from pyvac.views.request import Refuse
        from pyvac.models import Request
        from pyvac.views.request import Refuse
        from pyvac.models import Request
        from pyvac.views.request import Cancel
        from pyvac.models import Request
        from pyvac.views.request import Cancel
        from pyvac.models import Request
        from pyvac.views.request import Cancel
        from pyvac.models import Request
        from pyvac.views.request import Cancel
        from pyvac.views.request import Export
        from pyvac.views.request import Exported
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request, User, CPVacation
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send
        from pyvac.models import Request
        from pyvac.views.request import Send

        total_req = Request.find(self.session, count=True)
        view = Send(self.create_request({
            'days': 0.5,
            'date_from': '05/05/2015 - 05/05/2015',
            'type': '1',
            'breakdown': 'AM',
        }))()
        self.assertIsRedirect(view)
        self.assertEqual(Request.find(self.session, count=True), total_req + 1)

    def test_post_send_half_day_ko(self):
        self.config.testing_securitypolicy(userid='jdoe',
                                           permissive=True)
        total_req = Request.find(self.session, count=True)

        with freeze_time('2011-07-14',
                         ignore=['celery', 'psycopg2', 'sqlalchemy',
                                 'icalendar']):
            request = self.create_request({
                'days': 0.5,
                'date_from': '24/08/2011 - 24/08/2011',
                'type': '1',
                'breakdown': 'AM',
            })
            view = Send(request)()
        self.assertIsRedirect(view)
        expected = ['error;Invalid period: days already requested.']
        self.assertEqual(request.session.pop_flash(), expected)
        self.assertEqual(Request.find(self.session, count=True), total_req)


    def test_post_send_half_day_other_half_ok(self):