예제 #1
0
def rental_shell(inventory, name):
    rental_item = get_rental_item(inventory, name)
    days = user_days()
    core.rent_item(inventory, rental_item)
    cost = core.item_cost(inventory, rental_item, days)
    tax = core.get_tax(cost)
    deposit = core.get_deposit(inventory, rental_item)
    total = cost + tax + deposit
    print_receipt(name, rental_item, days, cost, tax, deposit, total)
    disk.write_history_file(inventory, rental_item, user_days, total, deposit)
예제 #2
0
def test_rent_item_out_of_stock():
    item = {
        'item_name': 'car',
        'base_rental_price': 2,
        'replacement_cost': 3,
        'in_stock': 0,
        'initial_stock': 5
    }
    core.rent_item(item)
    assert item['in_stock'] == -1
def renting(inventory, history):
    print_inventory(inventory)
    while True:
        choice = input(
            '\nPlease input which item you would like to rent or exit to leave: '
        )
        choice = choice.lower().strip()
        if choice in inventory:
            if inventory[choice]['amount'] <= 0:
                print('\nSorry, that item is not avaliable.')
            else:
                print(
                    '\nThe cost for the {} will be ${} when you return it . As for now your deposit price is ${}'
                    .format(
                        inventory[choice]['name'],
                        core.sales_tax(inventory[choice]['rent price']),
                        core.replacement_tax(
                            inventory[choice]['replacement price'])))
                inventory = core.rent_item(inventory, choice)
            return write_in_rent(inventory, choice, None)
        elif choice == 'exit':
            print('\nGoodbye')
            exit()
        elif choice not in inventory:
            print('\nPlease choose a valid option.')
예제 #4
0
def customer_path(identity, inventory, cart):
    ''' (str, list of dict, list of lists [dict, str]) -> NoneType

    Options for the customer when they run the application 
    '''
    username = user_login()
    while True:
        if username == 'back':
            _ = clear_screen()
            break
        choice = rent_or_return()
        customer_manifesto = disk.process_user_items(
            disk.read_manifesto('customer_manifesto.txt'))
        if choice == 'leave':
            _ = clear_screen()
            break
        if choice == 'rent':
            item_choice = which_item(inventory, 'rent', username,
                                     customer_manifesto)
            if item_choice == 'back':
                _ = clear_screen()
                continue
            core.rent_item(item_choice)
            print(
                f'1 {item_choice["item_name"]} has been added to your cart.\n\n'
            )
            core.add_item_to_cart(cart, item_choice, choice)
        if choice == 'return':
            item_choice = which_item(inventory, 'return', username,
                                     customer_manifesto)
            if item_choice == 'back':  # if the user wants to back out
                _ = clear_screen()
                continue
            elif item_choice:  # if the user can return something
                core.return_item(item_choice)
                print(
                    f'1 {item_choice["item_name"]} has been returned.  Please checkout to get your deposit back.\n\n'
                )
                core.add_item_to_cart(cart, item_choice, choice)
            else:  # if the user cannot return anything
                continue
        if choice == 'checkout':  #next on the agenda
            checkout_operations(inventory, cart, username, customer_manifesto)
예제 #5
0
def test_rent_item():
    inventory = {'brickcity': {'stock': 5}}

    result = core.rent_item(inventory, 'brickcity')

    assert inventory['brickcity']['stock'] == 4
예제 #6
0
def test_rent_item():
    assert core.rent_item(({
        'bikes': {
            'name': 'bike',
            'rent price': 25,
            'replacement price': 150,
            'amount': 10
        },
        'skateboards': {
            'name': 'skateboard',
            'rent price': 10,
            'replacement price': 80,
            'amount': 6
        },
        'scooters': {
            'name': 'scooter',
            'rent price': 15,
            'replacement price': 65,
            'amount': 8
        }
    }), 'bikes') == ({
        'bikes': {
            'name': 'bike',
            'rent price': 25,
            'replacement price': 150,
            'amount': 9
        },
        'skateboards': {
            'name': 'skateboard',
            'rent price': 10,
            'replacement price': 80,
            'amount': 6
        },
        'scooters': {
            'name': 'scooter',
            'rent price': 15,
            'replacement price': 65,
            'amount': 8
        }
    })

    def test_return_item():
        assert core.return_item(({
            'bikes': {
                'name': 'bike',
                'rent price': 25,
                'replacement price': 150,
                'amount': 10
            },
            'skateboards': {
                'name': 'skateboard',
                'rent price': 10,
                'replacement price': 80,
                'amount': 6
            },
            'scooters': {
                'name': 'scooter',
                'rent price': 15,
                'replacement price': 65,
                'amount': 8
            }
        }), 'bikes') == ({
            'bikes': {
                'name': 'bike',
                'rent price': 25,
                'replacement price': 150,
                'amount': 11
            },
            'skateboards': {
                'name': 'skateboard',
                'rent price': 10,
                'replacement price': 80,
                'amount': 6
            },
            'scooters': {
                'name': 'scooter',
                'rent price': 15,
                'replacement price': 65,
                'amount': 8
            }
        })