Esempio n. 1
0
def add_new_item():
    """Function to add a new item to the inventory"""
    global FULL_INVENTORY
    item_code = input("Enter item code: ")
    item_description = input("Enter item description: ")
    item_rental_price = input("Enter item rental price: ")

    # Get price from the market prices module
    item_price = market_prices.get_latest_price()

    is_furniture = input("Is this item a piece of furniture? (Y/N): ")
    if is_furniture.lower() == "y":
        item_material = input("Enter item material: ")
        item_size = input("Enter item size (S,M,L,XL): ")
        new_item = furniture_class.Furniture(item_code, item_description,
                                             item_price, item_rental_price,
                                             item_material, item_size)
    else:
        is_electric_appliance = input(
            "Is this item an electric appliance? (Y/N): ")
        if is_electric_appliance.lower() == "y":
            item_brand = input("Enter item brand: ")
            item_voltage = input("Enter item voltage: ")
            new_item = electric_appliances_class.ElectricAppliances(
                item_code, item_description, item_price, item_rental_price,
                item_brand, item_voltage)
        else:
            new_item = inventory_class.Inventory(item_code, item_description,
                                                 item_price, item_rental_price)
    FULL_INVENTORY[item_code] = new_item.return_as_dictionary()
    print("New inventory item added")
Esempio n. 2
0
def add_new_item():
    """
    This is a method to add new items to the inventory
    """

    product_info = {}
    product_info['product_code'] = input("Enter item code: ")
    product_info['description'] = input("Enter item description: ")
    product_info['rental_price'] = input("Enter item rental price: ")

    # Get price from the market prices module
    product_info['market_price'] = market_prices.get_latest_price(
        product_info['product_code'])

    is_furniture = input("Is this item a piece of furniture? (Y/N): ")
    if is_furniture.lower() == "y":
        product_info['material'] = input("Enter item material: ")
        product_info['size'] = input("Enter item size (S,M,L,XL): ")
        new_item = furniture_class.Furniture(product_info)
    else:
        is_electric_appliance = input(
            "Is this item an electric appliance? (Y/N): ")
        if is_electric_appliance.lower() == "y":
            product_info['brand'] = input("Enter item brand: ")
            product_info['voltage'] = input("Enter item voltage: ")
            new_item = electric_appliances_class.ElectricAppliances(
                product_info)
        else:
            new_item = inventory_class.Inventory(product_info)
    FULL_INVENTORY[
        product_info['product_code']] = new_item.return_as_dictionary()
    print("New inventory item added")
Esempio n. 3
0
def add_new_item():
    """gets information about a new item from user,
    then enters item into inventory"""
    code = input("Enter item code: ")
    description = input("Enter item description: ")
    rental_price = input("Enter item rental price: ")

    # Get price from the market prices module
    price = market_prices.get_latest_price(code)

    is_furniture = input("Is this item a piece of furniture? (Y/N): ")
    if is_furniture.lower() == "y":
        material = input("Enter item material: ")
        size = input("Enter item size (S,M,L,XL): ")
        new_item = furniture_class.Furniture(code, description, price,
         rental_price, material, size)
    else:
        is_electric_appliance = input("Is this item an electric appliance? (Y/N): ")
        if is_electric_appliance.lower() == "y":
            brand = input("Enter item brand: ")
            voltage = input("Enter item voltage: ")
            new_item = electric_appliances_class.ElectricAppliances(code, description, price,
                                                                    rental_price, brand, voltage)
        else:
            new_item = inventory_class.Inventory(code, description, price,
             rental_price)
    FULL_INVENTORY[code] = new_item.return_as_dictionary()
    print("New inventory item added")
 def test_inventory_class(self):
     """tests inventory class"""
     c = inv.Inventory("test product code", "test description", 52, "26")
     self.assertEqual(c.returnasdictionary(),
                      {'productcode': "test product code",
                       'description': "test description",
                       'marketprice': 52,
                       'rentalprice': "26",
                       })
Esempio n. 5
0
 def setUp(self):
     """Define set up characteristics of inventory tests."""
     print('setUp')
     self.item_code = 12345
     self.description = "First Product"
     self.market_price = 800
     self.rental_price = 25
     self.test_inv = inv.Inventory(self.item_code, self.description,
                                   self.market_price, self.rental_price)
     self.test_inv_dict = self.test_inv.return_as_dictionary()
Esempio n. 6
0
    def setUp(self):
        self.product_code = 24
        self.description = "Junk"
        self.market_price = get_latest_price(self.product_code)
        self.rental_price = 30

        self.inventory = inventory_class.Inventory(self.product_code,
                                                   self.description,
                                                   self.market_price,
                                                   self.rental_price)
Esempio n. 7
0
def add_new_item():
    """Add a new item to the inventory

    Note:
        I dislike this function.  It operates on a global instead of an arg,
        and returns nothing, instead printing to stdout.
        I'd prefer it to accept a dict as an arg then return the new dict,
        or raise an error if something goes wrong.

    """
    item_code = input("Enter item code: ")
    item_description = input("Enter item description: ")
    item_rental_price = input("Enter item rental price: ")
    item_price = get_price(item_code)

    is_furniture = input("Is this item a piece of furniture? (Y/N): ")

    if is_furniture.lower() == "y":
        item_material = input("Enter item material: ")
        item_size = input("Enter item size (S,M,L,XL): ")
        new_item = furniture_class.Furniture(item_code, item_description,
                                             item_price, item_rental_price,
                                             item_material, item_size)

    else:
        is_electric_appliance = \
            input("Is this item an electric appliance? (Y/N): ")

        if is_electric_appliance.lower() == "y":
            item_brand = input("Enter item brand: ")
            item_voltage = input("Enter item voltage: ")
            new_item = electric_appliances_class.ElectricAppliances(
                item_code, item_description, item_price, item_rental_price,
                item_brand, item_voltage)

        else:
            new_item = inventory_class.Inventory(item_code, item_description,
                                                 item_price, item_rental_price)

    FULL_INVENTORY[item_code] = new_item.return_as_dictionary()
    print("New inventory item added")
Esempio n. 8
0
def add_new_item():
    """Add new item to full_inventory"""

    # Consider passing as argument
    global full_inventory  # pylint: disable=global-statement, invalid-name

    item_code = input("Enter item code: ")
    item_description = input("Enter item description: ")
    item_rental_price = input("Enter item rental price: ")

    # Get price from the market prices module
    item_price = market_prices.get_latest_price(item_code)

    is_furniture = input("Is this item a piece of furniture? (Y/N): ")

    if is_furniture.lower() == "y":
        item_material = input("Enter item material: ")
        item_size = input("Enter item size (S,M,L,XL): ")
        new_item = furniture.Furniture(item_code, item_description, item_price,
                                       item_rental_price, item_material,
                                       item_size)

    else:
        is_electric_appliance = input("Is this item an electric appliance?"
                                      " (Y/N): ")

        if is_electric_appliance.lower() == "y":
            item_brand = input("Enter item brand: ")
            item_voltage = input("Enter item voltage: ")
            new_item = elec.ElectricAppliances(item_code, item_description,
                                               item_price, item_rental_price,
                                               item_brand, item_voltage)

        else:
            new_item = inventory.Inventory(item_code, item_description,
                                           item_price, item_rental_price)

    full_inventory[item_code] = new_item.return_as_dictionary()
    print("New inventory item added")
Esempio n. 9
0
 def setUp(self):
     """This method is executed prior to each test and it sets up
     the instances for the testing."""
     #print("from setup")
     self.inventory = ic.Inventory("000", "bag", "$50", "$10")
     self.result = self.inventory.return_as_dictionary()