Example #1
0
    def test_all_reservations_overlapping(self):
        # would fail if the second reservation was valid

        self.room1.reserve(start='2000-12-30', end='2001-01-22', size=1)
        self.room1.reserve(start='2000-11-30', end='2001-01-21', size=4, valid_until=datetime(1900, 10, 10))
        self.room2.reserve(start='2001-01-20', end='2001-02-11', size=2, valid_until=datetime(2100, 10, 10))

        reservation = self.room3.reserve(
            start='2001-01-05', end='2001-01-14', size=4, valid_until=datetime(1900, 10, 10))
        reservation.approve()
        self.room3.reserve(start='2001-01-10', end='2001-01-17', size=4)
        self.room4.reserve(start='2000-12-20', end='2001-02-18', size=7, valid_until=datetime(2100, 10, 10))

        start = datetime(2001, 01, 01)
        end = datetime(2001, 01, 31)
        data = {
            'start': start,
            'end': end,
            'required_size': 6,
        }
        searcher = ClustersSearcher(HotelRoom, Hotel, 'rooms')
        results = searcher.search(**data)

        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].name, 'Hotel 1')
Example #2
0
 def test_empty_clusters(self):
     start = datetime(2001, 01, 01)
     end = datetime(2001, 01, 31)
     data = {
         'start': start,
         'end': end,
         'required_size': 11,
     }
     searcher = ClustersSearcher(HotelRoom, Hotel, 'rooms')
     results = searcher.search(**data)
     self.assertEqual(len(results), 1)
     self.assertEqual(results[0].name, 'Hotel 2')
Example #3
0
    def test_the_need_to_switch_room(self):
        self.room3.reserve(start='2001-01-01', end='2001-01-15', size=5)
        self.room4.reserve(start='2001-01-01', end='2001-01-15', size=7)

        self.room3.reserve(start='2001-01-16', end='2001-01-25', size=7)
        self.room4.reserve(start='2001-01-16', end='2001-01-25', size=5)

        start = datetime(2001, 01, 01)
        end = datetime(2001, 01, 31)
        data = {
            'start': start,
            'end': end,
            'required_size': 7,
        }
        searcher = ClustersSearcher(HotelRoom, Hotel, 'rooms')

        results = searcher.search(**data)
        length = len(results)
        self.assertEqual(length, 1)
        self.assertEqual(results[0].name, 'Hotel 1')
Example #4
0
    def test_all_reservations_overlapping(self):
        self.room1.reserve(start='2000-12-30', end='2001-01-22', size=1)
        self.room1.reserve(start='2000-11-30', end='2001-01-21', size=1)
        self.room2.reserve(start='2001-01-20', end='2001-02-11', size=2)

        self.room3.reserve(start='2001-01-05', end='2001-01-14', size=4)
        self.room3.reserve(start='2001-01-10', end='2001-01-17', size=4)
        self.room4.reserve(start='2000-12-20', end='2001-02-18', size=7)

        start = datetime(2001, 01, 01)
        end = datetime(2001, 01, 31)
        data = {
            'start': start,
            'end': end,
            'required_size': 6,
        }
        searcher = ClustersSearcher(HotelRoom, Hotel, 'rooms')
        results = searcher.search(**data)

        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].name, 'Hotel 1')