Ejemplo n.º 1
0
    def setUp(self):
        self.product_code = 1
        self.description = "House"
        self.market_price = 4
        self.rental_price = 2

        self.inventory = Inventory(self.product_code, self.description, self.market_price, self.rental_price)
Ejemplo n.º 2
0
    def test_dictfunctions(self):
        ii = Inventory(24, "Test item", 200.00, 50.00)

        inv_dict = Fullinventory()

        inv_dict.add_inventory(24, ii.return_as_dictionary())

        self.assertEqual(
            inv_dict.full_inventory_dict[24], {
                'productCode': 24,
                'description': 'Test item',
                'marketPrice': 200.00,
                'rentalPrice': 50.0
            })

        self.assertEqual(
            inv_dict.get_inventory(), {
                24: {
                    'productCode': 24,
                    'description': 'Test item',
                    'marketPrice': 200.00,
                    'rentalPrice': 50.0
                }
            })

        self.assertEqual(
            inv_dict.get_inventory_item(24), {
                'productCode': 24,
                'description': 'Test item',
                'marketPrice': 200.00,
                'rentalPrice': 50.0
            })

        self.assertEqual(inv_dict.get_inventory_item(25), None)
Ejemplo n.º 3
0
    def __init__(self, productcode, description, marketprice, rentalprice,
                 material, size):
        Inventory.__init__(self, productcode, description, marketprice,
                           rentalprice)
        # Creates common instance variables from the parent class

        self.material = material
        self.size = size
Ejemplo n.º 4
0
    def __init__(self, productcode, description, marketprice, rentalprice,
                 brand, voltage):
        Inventory.__init__(self, productcode, description, marketprice,
                           rentalprice)
        # Creates common instance variables from the parent class

        self.brand = brand
        self.voltage = voltage
Ejemplo n.º 5
0
    def test_inventory(self):
        ii = Inventory(24, "Test item", 200.00, 50.00)

        self.assertEqual(
            ii.return_as_dictionary(), {
                'productCode': 24,
                'description': 'Test item',
                'marketPrice': 200.00,
                'rentalPrice': 50.0
            })
Ejemplo n.º 6
0
def add_new_item(fullinventory):
    """ add_new_item method"""
    item_code = input("Enter item code: ")
    item_description = input("Enter item description: ")
    item_rentalprice = 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(item_code, item_description, item_price,
                             item_rentalprice, item_material, item_size)
    else:

        is_electricappliance = input(
            "Is this item an electric appliance? (Y/N): ")
        if is_electricappliance.lower() == "y":
            item_brand = input("Enter item brand: ")
            item_voltage = input("Enter item voltage: ")
            new_item = ElectricAppliances(item_code, item_description,
                                          item_price, item_rentalprice,
                                          item_brand, item_voltage)
        else:
            new_item = Inventory(item_code, item_description, item_price,
                                 item_rentalprice)
    fullinventory[item_code] = new_item.returnas_dictionary()
    print("New inventory item added")
    return fullinventory
Ejemplo n.º 7
0
class TestInventory(TestCase):

    def setUp(self):
        self.product_code = 1
        self.description = "House"
        self.market_price = 4
        self.rental_price = 2

        self.inventory = Inventory(self.product_code, self.description, self.market_price, self.rental_price)

    def test_inventory_return_as_dictionay(self):
        assert self.inventory.return_as_dictionary() == {'product_code': 1, 'description': 'House', 'market_price': 4, 'rental_price': 2}
Ejemplo n.º 8
0
    def test_furniture(self):
        ii = Inventory(24, "Test item", 200.00, 50.00)
        fc = Furniture(ii, "Cloth", "XL")

        self.assertEqual(
            fc.return_as_dictionary(), {
                'productCode': 24,
                'description': 'Test item',
                'marketPrice': 200.00,
                'rentalPrice': 50.0,
                'material': 'Cloth',
                'size': 'XL'
            })
Ejemplo n.º 9
0
    def test_electricappliance(self):
        ii = Inventory(24, "Test item", 200.00, 50.00)
        ea = ElectricAppliances(ii, "Test Brand", "100V")

        self.assertEqual(
            ea.return_as_dictionary(), {
                'productCode': 24,
                'description': 'Test item',
                'marketPrice': 200.00,
                'rentalPrice': 50.0,
                'brand': 'Test Brand',
                'voltage': '100V'
            })
Ejemplo n.º 10
0
    def test_addnewinvitem(self):

        newitem = Inventory(24, 'Test item', 50.00, 60.00)
        mock_values = [24, 'Test item', 50.00, 'n', 'n']

        with mock.patch('builtins.input', side_effect=mock_values):
            try:
                tc.add_new_item()

                tc.get_latest_price = MagicMock(60.00)
                tc.get_latest_price.assert_called_with(24)

                tc.Inventory = MagicMock(newitem)
                tc.Inventory.assert_called_with(24, 'Test item', 50.00, 60.00)
            except NameError:
                assert (True)
Ejemplo n.º 11
0
    def test_addnewfuritem(self):

        newitem = Inventory(24, 'Test item', 50.00, 60.00)
        newfurn = Furniture(newitem, 'Cloth', 'S')
        mock_values = [24, 'Test item', 50.00, 'y', 'Cloth', 'S', 'n']

        with mock.patch('builtins.input', side_effect=mock_values):
            try:
                tc.add_new_item()

                tc.get_latest_price = MagicMock(60.00)
                tc.get_latest_price.assert_called_with(24)

                tc.Furniture = MagicMock(newfurn)
                tc.Furniture.assert_called_with(newitem, 'Cloth', 'S')
            except NameError:
                assert (True)
Ejemplo n.º 12
0
    def test_addnewapplitem(self):

        newitem = Inventory(24, 'Test item', 50.00, 60.00)
        newappli = ElectricAppliances(newitem, 'Maytag', '100V')
        mock_values = [24, 'Test item', 50.00, 'y', 'y', 'Maytag', '100V']

        with mock.patch('builtins.input', side_effect=mock_values):
            try:
                tc.add_new_item()

                tc.get_latest_price = MagicMock(60.00)
                tc.get_latest_price.assert_called_with(24)

                tc.ElectricAppliances = MagicMock(newappli)
                tc.ElectricAppliances.assert_called_with(
                    newitem, 'Maytag', '100V')
            except NameError:
                assert (True)
Ejemplo n.º 13
0
def add_new_item():
    """
    this function is for adding a new item
    """
    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 = 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(
            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 = ElectricAppliances(
                item_code, item_description, item_price,
                item_rental_price, item_brand, item_voltage)
        else:
            new_item = Inventory(
                item_code, item_description, item_price, item_rental_price)
    FULLINVENTORY[item_code] = new_item.return_as_dictionary()
    print("New inventory item added")
Ejemplo n.º 14
0
 def test_inventory(self):
     """ Test the adding of inventory item """
     expected = {'productCode': 'AX003C', 'description': 'Modulator',
                 'marketPrice': 1000, 'rentalPrice': 250}
     inventory_item = Inventory('AX003C', 'Modulator', 1000, 250)
     self.assertEqual(expected, inventory_item.return_as_dictionary())