Exemplo n.º 1
0
    def test_one_shift_in_range_returns_none_for_other_days(self):

        user = User('*****@*****.**', 'u3', username='******', _id='u3')
        user.save_to_database()

        # USER HAS SHIFT FOT ONLY MONDAY
        start = beginning_of_week()
        end = start + timedelta(seconds=1)
        # create 1 second shift
        shift = Shift(user._id, start, end)
        shift.save_to_database()

        schedule = Schedule(user._id)

        # Monday is not None
        self.assertEqual(type(schedule.shifts[0]), type(shift))
        self.assertEqual(schedule.row[1], None)
        self.assertEqual(schedule.row[2], None)
        self.assertEqual(schedule.row[3], None)
        self.assertEqual(schedule.row[4], None)
        self.assertEqual(schedule.row[5], None)
        self.assertEqual(schedule.row[6], None)

        Database.remove('users', {'user_id': user._id})
        Database.remove('shifts', {'user_id': user._id})
Exemplo n.º 2
0
    def test_monday_and_wednesday_day_are_shifts_rest_are_none(self):

        user = User('*****@*****.**', 'u4', username='******', _id='u4')
        user.save_to_database()

        # USER HAS SHIFT FOT ONLY MONDAY
        monday = beginning_of_week()
        wednesday = beginning_of_week(days=2)
        # create 1 second shift
        shift = Shift(user._id, monday, monday+timedelta(seconds=1))
        shift.save_to_database()
        shift = Shift(user._id, wednesday, wednesday+timedelta(seconds=1))
        shift.save_to_database()

        schedule = Schedule(user._id)

        # Monday is not None
        self.assertEqual(type(schedule.row[0]), type(shift))
        self.assertEqual(schedule.row[1], None)
        self.assertEqual(type(schedule.row[2]), type(shift))

        Database.remove('users', {'user_id': user._id})
        Database.remove('shifts', {'user_id': user._id})