# Path: pyvac/tests/case.py
# class ModelTestCase(TestCase):
# 
#     def setUp(self):
#         transaction.begin()
#         self.session = DBSession()
# 
#     def tearDown(self):
#         transaction.commit()


from datetime import datetime
from freezegun import freeze_time
from dateutil.relativedelta import relativedelta
from mock import patch, PropertyMock, MagicMock
from .case import ModelTestCase
        from pyvac.models import Group
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User, Request
        from pyvac.models import User, Request
        from pyvac.models import User, Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import User, VacationType
        from pyvac.models import User, VacationType
        from pyvac.models import User, VacationType
        from pyvac.models import User, VacationType
        from pyvac.models import VacationType
        from pyvac.models import VacationType
        from pyvac.models import VacationType
        from pyvac.models import User
        from pyvac.models import CPLUVacation, CompensatoireVacation, User
        from pyvac.models import CPVacation, User
        from pyvac.models import Sudoer
        from pyvac.models import Sudoer
        from pyvac.models import User
        from pyvac.models import Sudoer
        from pyvac.models import User
        with freeze_time('2014-12-25',
                         ignore=['celery', 'psycopg2', 'sqlalchemy',
                                 'icalendar']):
            with patch('pyvac.models.User.arrival_date',
                       new_callable=PropertyMock) as mock_foo:
                mock_foo.return_value = datetime(2014, 1, 1)
                expected = {'allowed': 10, 'left': 9.5, 'state': 'warning',
                            'taken': 0.5, 'year': 2014}
                self.assertEqual(user.get_rtt_usage(self.session), expected)
                # no RTT for us country
                user = User.by_login(self.session, 'manager3')
                self.assertIsInstance(user, User)
                self.assertEqual(user.country, 'us')
                self.assertIsNone(user.get_rtt_usage(self.session))

    def test_get_rtt_taken_year(self):
        user = User.by_login(self.session, 'jdoe')
        self.assertIsInstance(user, User)
        self.assertEqual(user.login, 'jdoe')
        self.assertEqual(user.name, 'John Doe')
        self.assertEqual(user.role, 'user')

        self.assertEqual(user.get_rtt_taken_year(self.session, 2014), 0.5)
        # no RTT for us country
        user = User.by_login(self.session, 'manager3')
        self.assertIsInstance(user, User)
        self.assertEqual(user.country, 'us')
        self.assertEqual(user.get_rtt_taken_year(self.session, 2014), 0)



# Path: pyvac/tests/case.py
# class ModelTestCase(TestCase):
# 
#     def setUp(self):
#         transaction.begin()
#         self.session = DBSession()
# 
#     def tearDown(self):
#         transaction.commit()


# Path: pyvac/tests/test_models.py
from datetime import datetime
from freezegun import freeze_time
from dateutil.relativedelta import relativedelta
from mock import patch, PropertyMock, MagicMock
from .case import ModelTestCase
        from pyvac.models import Group
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User
        from pyvac.models import User, Request
        from pyvac.models import User, Request
        from pyvac.models import User, Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import Request
        from pyvac.models import User, VacationType
        from pyvac.models import User, VacationType
        from pyvac.models import User, VacationType
        from pyvac.models import User, VacationType
        from pyvac.models import VacationType
        from pyvac.models import VacationType
        from pyvac.models import VacationType
        from pyvac.models import User
        from pyvac.models import CPLUVacation, CompensatoireVacation, User
        from pyvac.models import CPVacation, User
        from pyvac.models import Sudoer
        from pyvac.models import Sudoer
        from pyvac.models import User
        from pyvac.models import Sudoer
        from pyvac.models import User

        with freeze_time('2014-12-25',
                         ignore=['celery', 'psycopg2', 'sqlalchemy',
                                 'icalendar']):
            with patch('pyvac.models.User.arrival_date',
                       new_callable=PropertyMock) as mock_foo:
                mock_foo.return_value = datetime(2014, 1, 1)
                expected = {'allowed': 10, 'left': 9.5, 'state': 'warning',
                            'taken': 0.5, 'year': 2014}
                self.assertEqual(user.get_rtt_usage(self.session), expected)
                # no RTT for us country
                user = User.by_login(self.session, 'manager3')
                self.assertIsInstance(user, User)
                self.assertEqual(user.country, 'us')
                self.assertIsNone(user.get_rtt_usage(self.session))

    def test_get_rtt_taken_year(self):
        user = User.by_login(self.session, 'jdoe')
        self.assertIsInstance(user, User)
        self.assertEqual(user.login, 'jdoe')
        self.assertEqual(user.name, 'John Doe')
        self.assertEqual(user.role, 'user')

        self.assertEqual(user.get_rtt_taken_year(self.session, 2014), 0.5)
        # no RTT for us country
        user = User.by_login(self.session, 'manager3')
        self.assertIsInstance(user, User)
        self.assertEqual(user.country, 'us')
        self.assertEqual(user.get_rtt_taken_year(self.session, 2014), 0)



class RequestTestCase(ModelTestCase):