コード例 #1
0
def check_hotel(p_hotelid,eroom,droom,days_of_stay,booking_name,children,adult):
    try:
        totalfare=0
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        cur.execute("select efare,dfare from hotel where hotelid=:hotel_id",{"hotel_id":p_hotelid})
        flag=0
        check =False
        for row in cur:
            flag=1
            if(row[0]==None):
                raise InvalidHotelIdException();
            else:
                check=hotel_validation.validate_member(eroom,adult)
                if(check):
                    raise InvalidAdultExecutiveRoomsException()
                check=hotel_validation.validate_room_members(eroom,droom,children,adult);
                if(check):
                    raise InvalidNoOfRoomsException()
                check=hotel_validation.validate_days_of_stay(days_of_stay)
                if(check):
                    raise InvalidDaysOfStayException()
                check=hotel_validation.validate_booking_name(booking_name)
                if(check):
                    raise InvalidBookingNameException()
                hotel_validation.validate_no_of_children(children)
                hotel_validation.validate_no_of_adult(adult)
                if(booking_name==""):
                    raise InvalidBookingNameException()
                totalfare=(row[0]*eroom+row[1]*droom)*days_of_stay
                return totalfare
        if(flag==0):
            raise InvalidHotelIdException()
        
        for row in cur:
            totalfare=(row[0]*eroom+row[1]*droom)*days_of_stay
            return totalfare
    finally:
        cur.close()
        con.close()
コード例 #2
0
from validations.hotel_validation import validate_location
from validations.hotel_validation import validate_room_members
from validations.hotel_validation import validate_member
from exceptions.CustomExceptions import InvalidBookedFlightException
from exceptions.CustomExceptions import InvalidHotelLocationException
from exceptions.CustomExceptions import InvalidNoOfRoomsException
from exceptions.CustomExceptions import InvalidAdultExecutiveRoomsException

'''
positive test cases
'''
drooms = 2
erooms = 4
children = 2
adult = 4
c = validate_room_members(erooms,drooms,children,adult)
if(not c):
    print('valid no of rooms')

d = validate_member(erooms,adult)
if not d:
    print('Valid adult vs executive rooms')
    
'''
negative test cases
'''
try:
    list_of_flights=validate_booked_flight('000')
except InvalidBookedFlightException as e:
    print(e)