예제 #1
0
    def setUp(self) -> None:
        self.ride_controller = RideController()
        self.rider_service = rider_service
        self.booking_controller = BookingController()
        self.cab_controller = CabController()
        self.cab_service = cab_service

        self.driver_id = self.cab_controller.create_driver("Random_name")
        self.cab_id = self.cab_controller.create_cab(self.driver_id, 0, 0)
        self.my_cab = self.cab_service.getCab(self.cab_id)
예제 #2
0
    def setUp(self) -> None:
        self.trip_controller = TripController()
        self.cab_controller = CabController()
        self.rider_service = rider_service
        self.booking_service = booking_service
        self.booking_controller = BookingController()

        self.driver_id = self.cab_controller.create_driver("Ashwin")
        self.cab_id = self.cab_controller.create_cab(self.driver_id, 3, 2)

        self.rider_id = self.rider_service.createRider("Aditya", 1, 1)
        self.my_rider = rider_service.getRider(self.rider_id)

        self.booking_id = self.booking_controller.book_my_cab(
            self.rider_id, 3, 3)
        self.my_booking = self.booking_service.getBooking(self.booking_id)
예제 #3
0
class TestTripController(TestCase):
    def setUp(self) -> None:
        self.trip_controller = TripController()
        self.cab_controller = CabController()
        self.rider_service = rider_service
        self.booking_service = booking_service
        self.booking_controller = BookingController()

        self.driver_id = self.cab_controller.create_driver("Ashwin")
        self.cab_id = self.cab_controller.create_cab(self.driver_id, 3, 2)

        self.rider_id = self.rider_service.createRider("Aditya", 1, 1)
        self.my_rider = rider_service.getRider(self.rider_id)

        self.booking_id = self.booking_controller.book_my_cab(
            self.rider_id, 3, 3)
        self.my_booking = self.booking_service.getBooking(self.booking_id)

    def test_start_and_end_my_trip(self):
        booking_service.confirmBooking(self.booking_id)
        trip_id = self.trip_controller.start_my_trip(self.booking_id)
        my_trip = self.trip_controller.get_my_trip(trip_id)

        self.assertEqual(my_trip.trip_id, trip_id)
        self.assertEqual(my_trip.booking.booking_id,
                         self.my_booking.booking_id)
        self.assertEqual(my_trip.status, TripStatus.ACTIVE)

        self.trip_controller.end_my_trip(trip_id)

        self.assertEqual(my_trip.status, TripStatus.INACTIVE)
예제 #4
0
    def setUp(self) -> None:
        self.booking_controller = BookingController()
        self.rider_service = rider_service
        self.cab_controller = CabController()
        self.booking_service = booking_service

        # Create Cabs at multiple locations
        self.driver_1_id = self.cab_controller.create_driver("Ashwin")
        self.cab_1_id = self.cab_controller.create_cab(self.driver_1_id, 0, -2)

        self.driver_2_id = self.cab_controller.create_driver("Sayak")
        self.cab_2_id = self.cab_controller.create_cab(self.driver_2_id, -2,
                                                       -2)

        self.driver_3_id = self.cab_controller.create_driver("Sudeep")
        self.cab_3_id = self.cab_controller.create_cab(self.driver_3_id, 4, 4)
    def setUp(self) -> None:
        self.booking_controller = BookingController()
        self.cab_controller = CabController()
        self.rider_service = rider_service
        self.booking_service = booking_service
        self.cab_service = cab_service
        self.trip_service = trip_service

        self.first_rider = self.rider_service.createRider("Shreyas", 1, 1)
        self.second_rider = self.rider_service.createRider("Ashwin", 0, 0)
        self.third_rider = self.rider_service.createRider("Aditya", 3, 3)

        self.first_rider_destination_x = 5
        self.first_rider_destination_y = 5

        self.second_rider_destination_x = 4
        self.second_rider_destination_y = 4

        self.third_rider_destination_x = 6
        self.third_rider_destination_y = 6

        self.first_driver = self.cab_controller.create_driver("Amit")
        self.second_driver = self.cab_controller.create_driver("Sudeep")
        # self.third_driver = self.cab_controller.create_driver("Sumit")

        self.first_cab_id = self.cab_controller.create_cab(
            self.first_driver, -3, -3)
        self.second_cab_id = self.cab_controller.create_cab(
            self.second_driver, 0, 0)
예제 #6
0
class TestRideController(TestCase):
    def setUp(self) -> None:
        self.ride_controller = RideController()
        self.rider_service = rider_service
        self.booking_controller = BookingController()
        self.cab_controller = CabController()
        self.cab_service = cab_service

        self.driver_id = self.cab_controller.create_driver("Random_name")
        self.cab_id = self.cab_controller.create_cab(self.driver_id, 0, 0)
        self.my_cab = self.cab_service.getCab(self.cab_id)

    def test_create_rider(self):

        rider_id = self.ride_controller.create_rider("Rahul", 2, 3)
        my_rider = self.rider_service.getRider(rider_id)

        self.assertEqual(my_rider.rider_id, rider_id)
        self.assertEqual(my_rider.rider_name, "Rahul")
        self.assertEqual(my_rider.location.get_x_location(), 2)
        self.assertEqual(my_rider.location.get_y_location(), 3)

    def test_update_rider_location(self):
        rider_id = self.ride_controller.create_rider("Amit", 4, 5)
        my_rider = self.rider_service.getRider(rider_id)

        self.assertEqual(my_rider.rider_name, "Amit")
        self.assertEqual(my_rider.location.get_x_location(), 4)
        self.assertEqual(my_rider.location.get_y_location(), 5)

        self.ride_controller.update_rider_location(rider_id, 5, 5)
        self.assertEqual(my_rider.location.get_x_location(), 5)
        self.assertEqual(my_rider.location.get_y_location(), 5)

    def test_get_and_update_rider_history(self):

        rider_id = self.ride_controller.create_rider("Ashish", 1, 2)
        my_rider = self.rider_service.getRider(rider_id)

        booking_id = self.booking_controller.book_my_cab(rider_id, 0, 0)
        rider_history = self.ride_controller.get_rider_history(rider_id)

        self.assertEqual(rider_history[0].booking_id, booking_id)
예제 #7
0
class TestBookingController(TestCase):
    def setUp(self) -> None:
        self.booking_controller = BookingController()
        self.rider_service = rider_service
        self.cab_controller = CabController()
        self.booking_service = booking_service

        # Create Cabs at multiple locations
        self.driver_1_id = self.cab_controller.create_driver("Ashwin")
        self.cab_1_id = self.cab_controller.create_cab(self.driver_1_id, 0, -2)

        self.driver_2_id = self.cab_controller.create_driver("Sayak")
        self.cab_2_id = self.cab_controller.create_cab(self.driver_2_id, -2,
                                                       -2)

        self.driver_3_id = self.cab_controller.create_driver("Sudeep")
        self.cab_3_id = self.cab_controller.create_cab(self.driver_3_id, 4, 4)

    def test_book_my_cab(self):

        rider_id = rider_service.createRider("Aditya", -1, -1)
        my_rider = rider_service.getRider(rider_id)

        booking_id = self.booking_controller.book_my_cab(rider_id, 3, 3)
        my_booking = self.booking_service.getBooking(booking_id)

        self.assertEqual(booking_id, my_booking.booking_id)
        self.assertEqual(rider_id, my_booking.rider.rider_id)
        self.assertEqual("Aditya", my_booking.rider.rider_name)
        self.assertEqual(self.driver_1_id, my_booking.cab.driver.driver_id)
        self.assertEqual("Ashwin", my_booking.cab.driver.driver_name)

        self.assertEqual(my_booking.rider.location.get_x_location(),
                         my_rider.location.get_x_location())
        self.assertEqual(my_booking.rider.location.get_y_location(),
                         my_rider.location.get_y_location())

    def test_confirm_booking(self):

        rider_id = rider_service.createRider("Nithish", 4, 3)
        my_rider = rider_service.getRider(rider_id)

        booking_id = self.booking_controller.book_my_cab(rider_id, 6, 6)
        my_booking = self.booking_service.getBooking(booking_id)

        self.assertEqual(my_booking.booking_status, BookingStatus.CREATED)

        self.booking_service.confirmBooking(booking_id)
        self.assertEqual(my_booking.booking_status, BookingStatus.CONFIRMED)
        self.assertEqual(my_booking.cab.status, CabStatus.BOOKED)

    def test_cancel_booking(self):
        rider_id = rider_service.createRider("Sharan", 0, 0)
        my_rider = rider_service.getRider(rider_id)

        booking_id = self.booking_controller.book_my_cab(rider_id, 1, 1)
        my_booking = self.booking_service.getBooking(booking_id)

        self.assertEqual(my_booking.booking_status, BookingStatus.CREATED)

        self.booking_service.cancelBooking(booking_id)
        self.assertEqual(my_booking.booking_status, BookingStatus.CANCELLED)
        self.assertEqual(my_booking.cab.status, CabStatus.AVAILABLE)