예제 #1
0
    def setUp(self):
        """setup the test
        """
        # create a user
        self.test_user = User(
            name='Test User',
            login='******',
            email='*****@*****.**',
            password='******',
        )

        # vacation type
        self.personal_vacation = Type(
            name='Personal',
            code='PERS',
            target_entity_type='Vacation'
        )

        self.studio_vacation = Type(
            name='Studio Wide',
            code='STD',
            target_entity_type='Vacation'
        )

        self.kwargs = {
            'user': self.test_user,
            'type': self.personal_vacation,
            'start': datetime.datetime(2013, 6, 6, 10, 0),
            'end': datetime.datetime(2013, 6, 10, 19, 0)
        }

        self.test_vacation = Vacation(**self.kwargs)
예제 #2
0
    def setUp(self):
        """setup the test
        """
        super(VacationTestCase, self).setUp()

        # create a user
        from stalker import User
        self.test_user = User(
            name='Test User',
            login='******',
            email='*****@*****.**',
            password='******',
        )

        # vacation type
        from stalker import Type
        self.personal_vacation = Type(name='Personal',
                                      code='PERS',
                                      target_entity_type='Vacation')

        self.studio_vacation = Type(name='Studio Wide',
                                    code='STD',
                                    target_entity_type='Vacation')

        import datetime
        import pytz
        self.kwargs = {
            'user': self.test_user,
            'type': self.personal_vacation,
            'start': datetime.datetime(2013, 6, 6, 10, 0, tzinfo=pytz.utc),
            'end': datetime.datetime(2013, 6, 10, 19, 0, tzinfo=pytz.utc)
        }

        self.test_vacation = Vacation(**self.kwargs)
예제 #3
0
    def test_user_argument_is_not_a_User_instance(self):
        """testing if a TypeError will be raised when the user argument is not
        a stalker.models.auth.User instance
        """
        self.kwargs['user'] = '******'
        with pytest.raises(TypeError) as cm:
            Vacation(**self.kwargs)

        assert str(cm.value) == \
            'Vacation.user should be an instance of ' \
            'stalker.models.auth.User, not str'
예제 #4
0
    def test_user_argument_is_not_a_User_instance(self):
        """testing if a TypeError will be raised when the user argument is not
        a stalker.models.auth.User instance
        """
        self.kwargs['user'] = '******'
        with self.assertRaises(TypeError) as cm:
            Vacation(**self.kwargs)

        self.assertEqual(
            str(cm.exception),
            'Vacation.user should be an instance of stalker.models.auth.User, '
            'not str')
예제 #5
0
 def test_user_argument_is_None(self):
     """testing if the user argument can be set to None
     """
     self.kwargs['user'] = None
     Vacation(**self.kwargs)
예제 #6
0
 def test_user_argument_is_skipped(self):
     """testing if the user argument can be skipped skipped
     """
     self.kwargs.pop('user')
     Vacation(**self.kwargs)