Beispiel #1
0
    def test_main_integration(self):

        """Test all functions with main as a starting point"""
        price = market_prices.get_latest_price(0)

        #Adding non categorized inventory item with main

        input1 = ['1', 'shoe', '1', 'n', 'n']
        item1 = Inventory('1', 'shoe', price, '1')
        with patch('builtins.input', side_effect=input1):
            add_new_item()            
        #Adding furniture item with main
        input2 = ['2', 'chair', '2', 'y', 'wood', 'S']        
        item2 = Furniture('2', 'chair', price, '2', 'wood', 'S')
        with patch('builtins.input', side_effect=input2):
            add_new_item()
        #Adding electric appliance with main
        input3 = ['3', 'stove', '3', 'n', 'y', 'LG', '100']
        item3 = ElectricAppliances('3', 'stove', price, '3', 'LG', '100')
        with patch('builtins.input', side_effect=input3):
            add_new_item()
        actual_inventory = return_inventory()
        expected_inventory = {
            '1': item1.return_as_dictionary(),
            '2': item2.return_as_dictionary(),
            '3': item3.return_as_dictionary()}
        self.assertEqual(actual_inventory, expected_inventory)
Beispiel #2
0
 def __init__(self, product_code, description, market_price, rental_price,
              brand, voltage):
     """Creates common instance variables from the parent class"""
     Inventory.__init__(self, product_code, description, market_price,
                        rental_price)
     self.brand = brand
     self.voltage = voltage
Beispiel #3
0
 def __init__(self, product_code, description, market_price, rental_price,
              material, size):
     # Creates common instance variables from the parent class
     Inventory.__init__(self, product_code, description, market_price,
                        rental_price)
     self.material = material
     self.size = size
    def __init__(self, inventory_info, material, size):
        """Initializes the class info"""
        # Creates common instance variables from the parent class
        Inventory.__init__(self, inventory_info)

        self.material = material
        self.size = size
    def __init__(self, *args):
        # args -> product_code, description, market_price, rental_price, brand, voltage
        Inventory.__init__(self, args[0], args[1], args[2], args[3])
        # Creates common instance variables from the parent class

        self.brand = args[4]
        self.voltage = args[5]
Beispiel #6
0
    def test_inventory(self):
        inventory = Inventory(10, "thing", 24, 1000)

        out_dict = {"product_code": 10, "description": "thing",
        "market_price": 24, "rental_price": 1000}

        self.assertEqual(out_dict, inventory.return_as_dictionary())
Beispiel #7
0
    def __init__(self, product_code, description, market_price,
                 rental_price, material, size):

        Inventory.__init__(self, product_code, description, market_price,
                           rental_price)

        self.material = material
        self.size = size
Beispiel #8
0
    def __init__(self, inventory_info, brand, voltage):
        """Initializes the class info"""

        #Creates common instance variables from the parent class
        Inventory.__init__(self, inventory_info)

        self.brand = brand
        self.voltage = voltage
Beispiel #9
0
 def save_file(self, servings, in_out):
     inventory = Inventory()
     date = datetime.datetime.now()
     date_string = '%d/%d/%d' %(date.month, date.day, date.year)
     inv = inventory.update_file(self.barcode, servings, date_string, self.name, in_out)
     self.update_text(self.ui.status, '%s in inventory' %(inv))
     time.sleep(3)
     reset_settings()
    def __init__(self, product_code, description, market_price, rental_price,
                 material, size):
        # pylint: disable=too-many-arguments
        Inventory.__init__(self, product_code, description, market_price,
                           rental_price)
        # Creates common instance variables from the parent class

        self.material = material
        self.size = size
Beispiel #11
0
 def save_file(self, servings, in_out):
     inventory = Inventory()
     date = datetime.datetime.now()
     date_string = '%d/%d/%d' % (date.month, date.day, date.year)
     inv = inventory.update_file(self.barcode, servings, date_string,
                                 self.name, in_out)
     self.update_text(self.ui.status, '%s in inventory' % (inv))
     time.sleep(3)
     reset_settings()
Beispiel #12
0
    def __init__(self, product_code, description, market_price, rental_price,
                 brand, voltage):
        # pylint: disable=too-many-arguments
        Inventory.__init__(self, product_code, description, market_price,
                           rental_price)
        # Creates common instance variables from the parent class

        self.brand = brand
        self.voltage = voltage
Beispiel #13
0
    def test_inventory_initialization(self):
        """ Tests for successful, accurate initalization of Inventory. """

        new_product = Inventory(1, 'Chair', 100, 20)
        new_product_dict = new_product.return_as_dictionary()

        self.assertEqual(1, new_product_dict['product_code'])
        self.assertEqual('Chair', new_product_dict['description'])
        self.assertEqual(100, new_product_dict['market_price'])
        self.assertEqual(20, new_product_dict['rental_price'])
Beispiel #14
0
    def __init__(self, product_code, description, market_price, rental_price,
                 brand, voltage):
        """
        doc string
        """
        Inventory.__init__(self, product_code, description, market_price,
                           rental_price)

        self.brand = brand
        self.voltage = voltage
 def test_inventory(self):
     """Test that the inventory class returns the correct dict."""
     inv = Inventory(INV_CDE, INV_DSC, INV_MKT_PRC, INV_RNT_PRC)
     self.assertEqual(
         {
             'product_code': INV_CDE,
             'description': INV_DSC,
             'market_price': INV_MKT_PRC,
             'rental_price': INV_RNT_PRC
         }, inv.return_as_data_struct())
 def test_inventory_class(self):
     self.test_item = Inventory("123", "Table", "329.99", "59.99")
     self.test_dict = self.test_item.return_as_dictionary()
     self.assertDictEqual(
         self.test_dict, {
             "product_code": "123",
             "description": "Table",
             "market_price": "329.99",
             "rental_price": "59.99"
         })
 def test_inventory(self):
     """Tests the creation of an instance for inventory object"""
     test_dict = {
         'product_code': 6789,
         'description': 'Horse',
         'market_price': 50,
         'rental_price': 10
     }
     test_inv = Inventory(6789, 'Horse', 50, 10)
     self.assertEqual(test_dict, test_inv.return_as_dictionary())
Beispiel #18
0
 def test_inventory(self):
     """ tests inventory class returning a dict of all
         information about an item in the inventory"""
     testdict = {
         'productcode': '5',
         'description': 'shoe',
         'marketprice': '15',
         'rentalprice': '20',
     }
     inventory_test = Inventory(*testdict.values())
     inventory_dict_test = inventory_test.return_as_dictionary()
     self.assertDictEqual(testdict, inventory_dict_test)
Beispiel #19
0
    def test_integration(self):
        """Tests the integration of main with other modules"""
        new_item = Inventory(1, 'horse', 50, 10)
        new_electric = ElectricAppliances(2, 'horse', 50, 10, 'Sony', 5)
        new_furniture = Furniture(3, 'horse', 50, 10, 'leather', 'huge')

        new_item_specs = new_item.return_as_dictionary()
        new_electric_specs = new_electric.return_as_dictionary()
        new_furniture_specs = new_furniture.return_as_dictionary()

        self.assertEqual(1, new_item_specs['product_code'])
        self.assertEqual(2, new_electric_specs['product_code'])
        self.assertEqual(3, new_furniture_specs['product_code'])
Beispiel #20
0
    def test_inventory_class(self):
        """Test for the Inventory class."""
        inventory_test = Inventory("GI-2", "Table", 500, 60)

        inventory_test_dict = {
            "product_code": "GI-2",
            "description": "Table",
            "market_price": 500,
            "rental_price": 60
        }

        self.assertDictEqual(vars(inventory_test), inventory_test_dict)
        self.assertDictEqual(inventory_test.return_as_dictionary(), inventory_test_dict)
 def setUp(self):
     """Gives set up parameters"""
     self.product_code = '26'
     self.description = 'couch'
     self.market_price = "$50"
     self.rental_price = "$20"
     self.test_inventory = Inventory(self.product_code, self.description,
                                     self.market_price, self.rental_price)
     self.expected_dict = {
         'product_code': self.product_code,
         'description': self.description,
         'market_price': self.market_price,
         'rental_price': self.rental_price
     }
Beispiel #22
0
    def __init__(
            self,
            product_code,
            description,
            market_price,
            rental_price,
            *args  # brand, voltage
    ):
        Inventory.__init__(
            self, product_code, description, market_price, rental_price
        )  # Creates common instance variables from the parent class

        self.brand = args[0]
        self.voltage = args[1]
    def __init__(
            self,
            product_code,
            description,
            market_price,
            rental_price,
            *args  # material, size
    ):

        Inventory.__init__(
            self, product_code, description, market_price, rental_price
        )  # Creates common instance variables from the parent class
        self.material = args[0]
        self.size = args[1]
Beispiel #24
0
    def return_as_dictionary(self):
        """Function to return Inventory as dictionary"""
        output_dict = Inventory.return_as_dictionary(self)
        output_dict['brand'] = self.brand
        output_dict['voltage'] = self.voltage

        return output_dict
    def return_as_dictionary(self):
        """Returns info on item as a dictionary"""
        output_dict = Inventory.return_as_dictionary(self)
        output_dict['material'] = self.material
        output_dict['size'] = self.size

        return output_dict
    def return_as_dictionary(self):
        """Function to store furniture as a data dictionary"""
        output_dict = Inventory.return_as_dictionary(self)
        output_dict['material'] = self.material
        output_dict['size'] = self.size

        return output_dict
Beispiel #27
0
    def return_as_dictionary(self):
        """method docstring"""
        output_dict = Inventory.return_as_dictionary(self)
        output_dict['material'] = self.material
        output_dict['size'] = self.size

        return output_dict
    def return_as_dictionary(self):
        """Returns a dictionary of the furniture information"""
        output_dict = Inventory.return_as_dictionary(self)
        output_dict['material'] = self.material
        output_dict['size'] = self.size

        return output_dict
Beispiel #29
0
    def return_as_dictionary(self):
        '''Returns the furniture inventory as a dictionary'''
        output_dict = Inventory.return_as_dictionary(self)
        output_dict['material'] = self.material
        output_dict['size'] = self.size

        return output_dict
Beispiel #30
0
def add_new_item():
    """
    add a new item
    :return:
    """
    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(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_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)

    FULL_INVENTORY[item_code] = new_item.return_as_dictionary()
    print("New inventory item added")
    def return_as_dictionary(self):
        """method docstring"""
        output_dict = Inventory.return_as_dictionary(self)
        output_dict['brand'] = self.brand
        output_dict['voltage'] = self.voltage

        return output_dict