示例#1
0
文件: tests.py 项目: mbad/kitabu
 def reserve2():
     sleep(0.5)
     with self.assertRaises(SizeExceeded):
         TestReservationGroup.reserve(
             (self.other_room, {'start': '2014-05-01', 'end': '2014-05-02', 'size': 2}),
             (self.room, {'start': '2014-05-01', 'end': '2014-05-02', 'size': 2}),
             delay_between_reservations=1,
         )
示例#2
0
文件: tests.py 项目: mbad/kitabu
    def test_improper_group_reservation(self):
        initial_reservation_count = RoomReservation.objects.count()
        initial_group_count = TestReservationGroup.objects.count()

        with self.assertRaises(ReservationError):
            TestReservationGroup.reserve(
                (self.room5, {'start': '2012-04-01', 'end': '2012-05-12', 'size': 3}),
                (self.room1, {'start': '2012-04-01', 'end': '2012-05-12', 'size': 1}),
                (self.room3, {'start': '2012-04-01', 'end': '2012-05-12', 'size': 5})
            )

        self.assertEqual(RoomReservation.objects.count(), initial_reservation_count,
                         'There should be no reservation objects added to the database')
        self.assertEqual(TestReservationGroup.objects.count(), initial_group_count,
                         'There should be no group objects added to the database')
示例#3
0
文件: tests.py 项目: mbad/kitabu
    def test_proper_group_reservation(self):
        initial_reservation_count = RoomReservation.objects.count()
        initial_group_count = TestReservationGroup.objects.count()

        group = TestReservationGroup.reserve(
            (self.room5, {'start': '2012-04-01', 'end': '2012-05-12', 'size': 3}),
            (self.room1, {'start': '2012-04-01', 'end': '2012-05-12', 'size': 1}),
            (self.room3, {'start': '2012-04-01', 'end': '2012-05-12', 'size': 2})
        )
        reservations = group.reservations.all()

        self.assertEqual(len(reservations), 3, 'There should be 3 reservation objects in the returned group')
        self.assertEqual(reservations[0].size, 3, 'First reservation should have size equal to 3')
        self.assertEqual(RoomReservation.objects.count(), initial_reservation_count + 3,
                         'There should be 3 reservation objects added to the database')
        self.assertEqual(TestReservationGroup.objects.count(), initial_group_count + 1,
                         'There should be 1 group object added to the database')
示例#4
0
文件: tests.py 项目: mbad/kitabu
 def reserve1():
     TestReservationGroup.reserve(
         (self.room, {'start': '2014-05-01', 'end': '2014-05-02', 'size': 2}),
         (self.other_room, {'start': '2014-05-01', 'end': '2014-05-02', 'size': 2}),
         delay_between_reservations=1,
     )