Exemplo n.º 1
0
    def test_free_seats_in_non_empty_train(self):
        train_info = TrainInfo(
            build_seats_data(total_seats=10,
                             reserved_seats=1,
                             booking_reference=TEST_BOOKING_REFERENCE))

        self.assertEqual(['2A'], train_info.get_some_free_seat_ids(1))
        self.assertEqual(['2A', '3A'], train_info.get_some_free_seat_ids(2))
Exemplo n.º 2
0
    def test_reserved_seat_count_of_train_of_10_seats_and_one_reserved_seat(
            self):
        train_info = TrainInfo(
            build_seats_data(total_seats=10,
                             reserved_seats=1,
                             booking_reference=TEST_BOOKING_REFERENCE))

        self.assertEqual(1, train_info.reserved_seat_count())
Exemplo n.º 3
0
    def test_remaining_capacity_of_train_of_10_seats_and_one_reserved_seat(
            self):
        train_info = TrainInfo(
            build_seats_data(total_seats=10,
                             reserved_seats=1,
                             booking_reference=TEST_BOOKING_REFERENCE))

        self.assertTrue(train_info.can_reserve_seats(6))
        self.assertFalse(train_info.can_reserve_seats(7))
    def test_cant_reserve_one_seat_in_max_capacity_coach(self):
        self.train_data_service.obtain_info_for_train.return_value = \
            TrainInfo(build_seats_data(total_seats=10,
                                       reserved_seats=7,
                                       booking_reference=TEST_BOOKING_REFERENCE))

        reservation = self.ticket_office.reserve(TRAIN_ID, 1)

        self.assertEqual(build_empty_reservation(), reservation)
    def setUp(self):
        self.train_data_service = Mock(IObtainTrainInfo)
        self.train_data_service.obtain_info_for_train.return_value = \
            TrainInfo(build_seats_data(total_seats=10))

        self.booking_reference_service = Mock(IObtainBookingReferences)
        self.booking_reference_service.obtain_booking_reference.return_value = \
            TEST_BOOKING_REFERENCE

        # noinspection PyTypeChecker
        self.ticket_office = TicketOffice(self.train_data_service,
                                          self.booking_reference_service)
Exemplo n.º 6
0
    def test_remaining_capacity_of_empty_train_for_10_seats(self):
        train_info = TrainInfo(build_seats_data(total_seats=10))

        self.assertTrue(train_info.can_reserve_seats(7))
        self.assertFalse(train_info.can_reserve_seats(8))
Exemplo n.º 7
0
    def test_free_seats_in_empty_train(self):
        train_info = TrainInfo(build_seats_data(total_seats=10))

        self.assertEqual(['1A'], train_info.get_some_free_seat_ids(1))
        self.assertEqual(['1A', '2A'], train_info.get_some_free_seat_ids(2))
Exemplo n.º 8
0
    def test_reserved_seat_count_of_an_empty_train_of_10_seats(self):
        train_info = TrainInfo(build_seats_data(total_seats=10))

        self.assertEqual(0, train_info.reserved_seat_count())