def test_init(self):
     Couch = Furniture(62, "Couch", 2000, 150, "Leather", "Sectional")
     self.assertEqual(Couch.product_code, 62)
     self.assertEqual(Couch.description, "Couch")
     self.assertEqual(Couch.market_price, 2000)
     self.assertEqual(Couch.rental_price, 150)
     self.assertEqual(Couch.material, "Leather")
     self.assertEqual(Couch.style, "Sectional")
Beispiel #2
0
    def test_return_as_dictionary(self):

        couch = Furniture(3, 'comfy', 500, 600, 'leather', 'M')

        test_dictionary = {
            'product_code': 3,
            'description': 'comfy',
            'market_price': 500,
            'rental_price': 600,
            'material': 'leather',
            'size': 'M'
        }

        for key, value in test_dictionary.items():
            self.assertEqual(value, couch.return_as_dictionary()[f'{key}'])

        self.assertEqual(dict, type(couch.return_as_dictionary()))
Beispiel #3
0
    def test_return_as_dictionary(self):
        """ Test the return as dictionary method """

        test_inventory = Furniture(123, "chair", 100, 50, "wood",
                                   "m").return_as_dictionary()

        self.assertEqual(test_inventory['material'], 'wood')
        self.assertEqual(test_inventory['size'], 'm')
Beispiel #4
0
 def test_init(self):
     """Check expected values at object init."""
     test_obj = Furniture(*self.input)
     self.assertEqual(test_obj.product_code, 'PC')
     self.assertEqual(test_obj.description, 'D')
     self.assertEqual(test_obj.market_price, 'MP')
     self.assertEqual(test_obj.rental_price, 'RP')
     self.assertEqual(test_obj.material, 'M')
     self.assertEqual(test_obj.size, 'S')
 def test_return_as_dictionary(self):
     Couch_dict = Furniture(62, "Couch", 2000, 150, "Leather",
                            "Sectional").return_as_dictionary()
     self.assertEqual(Couch_dict['product_code'], 62)
     self.assertEqual(Couch_dict['description'], "Couch")
     self.assertEqual(Couch_dict['market_price'], 2000)
     self.assertEqual(Couch_dict['rental_price'], 150)
     self.assertEqual(Couch_dict['material'], "Leather")
     self.assertEqual(Couch_dict['style'], "Sectional")
Beispiel #6
0
 def test_init(self):
     """Test init"""
     test_obj = Furniture(1, 2, 3, 4, 5, 6)
     self.assertEqual(test_obj.product_code, 1)
     self.assertEqual(test_obj.description, 2)
     self.assertEqual(test_obj.market_price, 3)
     self.assertEqual(test_obj.rental_price, 4)
     self.assertEqual(test_obj.material, 5)
     self.assertEqual(test_obj.size, 6)
 def test_init(self):
     """ Test init """
     chair = Furniture(123, "chair", 100, 50, "wood", "m")
     self.assertEqual(chair.product_code, 123)
     self.assertEqual(chair.description, "chair")
     self.assertEqual(chair.market_price, 100)
     self.assertEqual(chair.rental_price, 50)
     self.assertEqual(chair.material, "wood")
     self.assertEqual(chair.size, "m")
    def test_module(self):
        """ Test out inventory items """
        inventory_item = Inventory(1, 'stapler', 10, 5)
        furniture_item = Furniture(2, 'sofa', 20, 10, 'wood', 'king')
        electric_item = ElectricAppliances(3, 'boiler', 30, 15, '', 8)

        inventory_item_info = inventory_item.return_as_dictionary()
        furniture_item_info = furniture_item.return_as_dictionary()
        electric_item_info = electric_item.return_as_dictionary()

        self.assertEqual(1, inventory_item_info['product_code'])
        self.assertEqual('stapler', inventory_item_info['description'])

        self.assertEqual(2, furniture_item_info['product_code'])
        self.assertEqual('sofa', furniture_item_info['description'])

        self.assertEqual(3, electric_item_info['product_code'])
        self.assertEqual('boiler', electric_item_info['description'])
Beispiel #9
0
 def test_return_dict(self):
     """Test return as dict func"""
     test_obj = Furniture(1, 2, 3, 4, 5, 6).return_as_dictionary()
     self.assertEqual(test_obj['product_code'], 1)
     self.assertEqual(test_obj['description'], 2)
     self.assertEqual(test_obj['market_price'], 3)
     self.assertEqual(test_obj['rental_price'], 4)
     self.assertEqual(test_obj['material'], 5)
     self.assertEqual(test_obj['size'], 6)
 def test_return_as_dictionary(self):
     """ Test the return as dictionary method """
     chair_dict = Furniture(123, "chair", 100, 50, "wood",
                            "m").return_as_dictionary()
     self.assertEqual(chair_dict['product_code'], 123)
     self.assertEqual(chair_dict['description'], "chair")
     self.assertEqual(chair_dict['market_price'], 100)
     self.assertEqual(chair_dict['rental_price'], 50)
     self.assertEqual(chair_dict['material'], 'wood')
     self.assertEqual(chair_dict['size'], 'm')
Beispiel #11
0
    def test_create_furniture(self):
        product_code = 'CH_01'
        description = 'Lounger'
        market_price = 999.99
        rental_price = 89.00
        material = 'Fabric'
        size = 'L'

        expectedDict = {
            'product_code': product_code,
            'description': description,
            'market_price': market_price,
            'rental_price': rental_price,
            'material': material,
            'size': size
        }

        furniture = Furniture(product_code, description, market_price, rental_price, material, size)
        self.assertEqual(furniture.return_as_dictionary(), expectedDict)
    def test_return_as_dictionary(self):
        '''Tests the return_as_dictionary function'''

        product = Furniture(product_code='M8421',
                            description='Thingabob',
                            market_price=25.99,
                            rental_price=4.99,
                            material='wood',
                            size='X-Large')

        test_dict = {}
        test_dict['product_code'] = 'M8421'
        test_dict['description'] = 'Thingabob'
        test_dict['market_price'] = 25.99
        test_dict['rental_price'] = 4.99
        test_dict['material'] = 'wood'
        test_dict['size'] = 'X-Large'

        self.assertDictEqual(test_dict, product.return_as_dictionary())
Beispiel #13
0
 def test_init_furniture(self):
     """Tests instance creation of Furniture"""
     furniture = Furniture("2", "Chair", "25", "2", "Wood", "L")
     self.assertTrue(furniture)
     self.assertEqual(furniture.product_code, "2")
     self.assertEqual(furniture.description, "Chair")
     self.assertEqual(furniture.market_price, "25")
     self.assertEqual(furniture.rental_price, "2")
     self.assertEqual(furniture.material, "Wood")
     self.assertEqual(furniture.size, "L")
    def test_add_furniture(self):
        """creates an object of the Furniture class"""
        furniture = Furniture("2222", "Chair", "$200", "$150", "Wood", "Small")

        self.assertEqual("2222", furniture.product_code)
        self.assertEqual("Chair", furniture.description)
        self.assertEqual("$200", furniture.market_price)
        self.assertEqual("$150", furniture.rental_price)
        self.assertEqual("Wood", furniture.material)
        self.assertEqual("Small", furniture.size)
Beispiel #15
0
    def test_furniture_class(self):
        """ Furniture class test """
        product_code = 5678
        description = 'test furniture article'
        market_price = 5678.90
        rental_price = 56.78
        material = 'cloth'
        size = 'large'

        test_article = Furniture(product_code, description, market_price,
                                 rental_price, material, size)
        test_dict = test_article.return_as_dictionary()

        self.assertEqual(test_dict['product_code'], product_code)
        self.assertEqual(test_dict['description'], description)
        self.assertEqual(test_dict['market_price'], market_price)
        self.assertEqual(test_dict['rental_price'], rental_price)
        self.assertEqual(test_dict['material'], material)
        self.assertEqual(test_dict['size'], size)
 def test_furnitiure(self):
     code = 1
     description = "Table"
     market_price = 300
     rental_price = 25
     material = "Wood"
     size = "M"
     my_f = Furniture(code, description, market_price, rental_price,
                      material, size)
     my_list = []
     my_list = my_f.return_as_dictionary()
     my_answer = {
         'product_code': 1,
         'description': 'Table',
         'market_price': 300,
         'rental_price': 25,
         'material': "Wood",
         "size": "M"
     }
     self.assertEqual(my_answer, my_list)
    def test_furniture(self):
        """Test item initialization"""
        item = Furniture(product_code=2,
                         description='Couch',
                         market_price=3000,
                         rental_price=500,
                         material='Leather',
                         size='L')

        self.assertEqual(item.description, 'Couch')
        self.assertEqual(item.material, 'Leather')
Beispiel #18
0
def add_new_item():
    """ Add a new item to the 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(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 testFurniture(self):
     """Testing of Furniture initialization"""
     test_furniture = Furniture(1, "dining_table_description", 400, 50,
                                "glass", "L")
     assert test_furniture.product_code == 1
     assert test_furniture.description == "dining_table_description"
     assert test_furniture.market_price == 400
     assert test_furniture.rental_price == 50
     assert test_furniture.material == "glass"
     assert test_furniture.size == "L"
     test_actualoutput = test_furniture.return_as_dictionary()
     test_expectedoutput = {
         'product_code': 1,
         'description': "dining_table_description",
         'market_price': 400,
         'rental_price': 50,
         'material': "glass",
         'size': "L"
     }
     assert test_actualoutput == test_expectedoutput
     self.assertDictEqual(test_actualoutput, test_expectedoutput)
Beispiel #20
0
def test_init_furniture():
    """Tests that furniture class initializes correctly"""
    product_dict = {}
    product_dict['product_code'] = 100
    product_dict['description'] = 'Chair'
    product_dict['market_price'] = 200
    product_dict['rental_price'] = 50
    product_dict['material'] = 'Leather'
    product_dict['size'] = 'L'

    chair = Furniture(**product_dict)

    print(chair.return_as_dictionary())
    print(product_dict)

    assert chair.product_code == product_dict['product_code']
    assert chair.description == product_dict['description']
    assert chair.market_price == product_dict['market_price']
    assert chair.rental_price == product_dict['rental_price']
    assert chair.material == product_dict['material']
    assert chair.size == product_dict['size']
Beispiel #21
0
def test_furniture():
    """
    tests initializing function of furniture class
    """
    chair = Furniture(4000, "lawn chair", 5.00, 6.00, "wood", "5' x 11'")

    assert chair.product_code == 4000
    assert chair.description == "lawn chair"
    assert chair.market_price == 5.00
    assert chair.rental_price == 6.00
    assert chair.material == "wood"
    assert chair.size == "5' x 11'"
    def setUp(self):
        self.FULL_INVENTORY = {}
        self.SIMPLE_INVENTORY = {}

        # setup refrigerator in inventory
        self.refrigerator = ElectricAppliances(product_code=1,
                                               description='refrigerator',
                                               market_price=24,
                                               rental_price=15,
                                               brand='kenmore',
                                               voltage=120)
        refrigerator_output = self.refrigerator.return_as_dictionary()
        item_code = refrigerator_output['product_code']
        self.FULL_INVENTORY[
            item_code] = self.refrigerator.return_as_dictionary()

        # setup sofa in inventory
        self.sofa = Furniture(product_code=2,
                              description='sofa',
                              market_price=24,
                              rental_price=12,
                              material='leather',
                              size='L')
        sofa_output = self.sofa.return_as_dictionary()
        item_code = sofa_output['product_code']
        self.FULL_INVENTORY[item_code] = self.sofa.return_as_dictionary()

        # setup a simple inventory to test class
        self.simple_inventory = Inventory(product_code=1,
                                          description='refrigerator',
                                          market_price=24,
                                          rental_price=15)
        invetory_output = self.simple_inventory.return_as_dictionary()
        item_code = invetory_output['product_code']
        self.SIMPLE_INVENTORY[item_code] = invetory_output

        # user inputs
        self.update_inventory = [[
            1, 'refrigerator', 15, 'n', 'y', 'kenmore', 120
        ], [2, 'sofa', 12, 'y', 'leather', 'L'], [3, 'hops', 20, 'n', 'n']]
Beispiel #23
0
def add_new_item():
    """
    What does this do?
    Adding new item into inventory system by 3 types.
    1) Base inventory
    2) Furniture.
    3) Electric.
    """
    # global FULL_INVENTORY
    item_code = input("Enter item code: ")
    item_description = input("Enter item description: ")
    item_rent_price = int(input("Enter item rental price: "))

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

    is_funiture = input("Is this item a piece of furniture? (Y/N): ")
    if is_funiture.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_rent_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_rent_price,
                item_brand, item_voltage)
        else:
            new_item = Inventory(item_code, item_description,
                                 item_price, item_rent_price)

    FULL_INVENTORY[item_code] = new_item.return_as_dictionary()

    print(FULL_INVENTORY)  # for testing only to be deleted.
    print("New inventory item added")
Beispiel #24
0
 def test_init(self):
     product = Furniture(product_code="BigOlCouch",
                         description="Big, old.",
                         market_price=999.99,
                         rental_price=99.99,
                         material="wood",
                         size="XXL")
     self.assertEqual("BigOlCouch", product.product_code)
     self.assertEqual("Big, old.", product.description)
     self.assertEqual(999.99, product.market_price)
     self.assertEqual(99.99, product.rental_price)
     self.assertEqual("wood", product.material)
     self.assertEqual("XXL", product.size)
Beispiel #25
0
    def test_furniture(self):

        elect_app1 = {
            product_code: '001',
            description: 'elect_1',
            market_price: '$25',
            rental_price: '$15',
            material: 'material1',
            size: 'size1'
        }

        
        self.assertEqual(elect_app1, Furniture('001', 'elect_1', '$25', '$15', 'material1', 'size1'));
Beispiel #26
0
 def test_return(self):
     """Test dictionary for Furniture"""
     pro_dict = Furniture(200, "Chair", 150, 50, "Wood",
                          "Small").return_as_dictionary()
     self.assertEqual(
         pro_dict, {
             "product_code": 200,
             "description": "Chair",
             "market_price": 150,
             "rental_price": 50,
             "material": "Wood",
             "size": "Small"
         })
    def test_integration(self):
        """Integration test function"""
        test_market_price = market_prices.get_latest_price('item_code')
        test_inventory_data = [1, "dining_table_description", 400, 'n', 'n']
        with patch('builtins.input', side_effect=test_inventory_data):
            main.add_new_item()

        test_inventory_object = Inventory(1, "dining_table_description", test_market_price, 400)
        print(test_inventory_object)

        # test_expected_inventory_data = {'product_code': 1, 'description': 'dining_table_description',
        #                                'market_price': 24, 'rental_price': 400}
        # self.assertDictEqual(test_inventory_data_values, test_expected_inventory_data)

        test_furniture_data = [2, "bed", "500", 'y', 'teak', 'L']
        with patch('builtins.input', side_effect=test_furniture_data):
            main.add_new_item()

        test_furniture_object = Furniture(2, "bed", test_market_price, "500", 'teak', 'L')




        # test_electric_data = [1, 'refregirator_description', 400, 'n', 'y', 'samsung', '110v']
        # with patch('builtins.input', side_effect=test_electric_data):
        #     main.add_new_item()
        #     print(main.FULL_INVENTORY[test_electric_data[0]])
        #     test_electric_data_values = main.FULL_INVENTORY[test_electric_data[0]]
        #
        # test_expected_electric_data = {'product_code': 1, 'description': 'refregirator_description',
        #                                'market_price': 24, 'rental_price': 400, 'brand': 'samsung', 'voltage': '110v'}
        # self.assertDictEqual(test_expected_electric_data, test_electric_data_values)

        full_data_main = main.FULL_INVENTORY
        expected_data_main = {
            1: test_inventory_object.return_as_dictionary(),
            2: test_furniture_object.return_as_dictionary()}
        self.assertEqual(full_data_main, expected_data_main)
    def setUp(self):
        """set up instance of each sub class"""
        self.furniture = Furniture(100, "test chair", 20, (1.5, "day"), "wood",
                                   "Large")

        self.appliance = ElectricAppliances(200, "test lamp", 30, (2.5, "day"),
                                            "basic", "110V")
        self.appliance_expected_output = {
            "product_code": 200,
            "description": "test lamp",
            "market_price": 30,
            "rental_price": (2.5, "day"),
            "brand": "basic",
            "voltage": "110V",
        }
        self.furniture_expected_output = {
            "product_code": 100,
            "description": "test chair",
            "market_price": 20,
            "rental_price": (1.5, "day"),
            "material": "wood",
            "size": "Large",
        }
    def test_init(self):
        '''Tests the _init_ function'''

        product = Furniture(product_code='M8421',
                            description='Thingabob',
                            market_price=25.99,
                            rental_price=4.99,
                            material='wood',
                            size='X-Large')

        self.assertEqual('M8421', product.product_code)
        self.assertEqual('Thingabob', product.description)
        self.assertEqual(25.99, product.market_price)
        self.assertEqual(4.99, product.rental_price)
    def test_furniture(self):
        # Set up test furniture
        attributes = [
            'product_code', 'description', 'market_price', 'rental_price',
            'material', 'size'
        ]
        values = ['123', 'Chair', 100.0, 80.0, 'fabric', 'L']

        # Initialize (order of values must match inputs)
        furniture = Furniture(*values)

        # Ensure that attributes match input values
        for attr, val in zip(attributes, values):
            self.assertEqual(getattr(furniture, attr), val)

        # Ensure that conversion to dict works properly
        output_dict = furniture.return_as_dictionary()

        # Ensure that each attribute is in dictionary and that dict value
        # matches attribute value
        for attr, val in zip(attributes, values):
            self.assertIn(attr, output_dict)
            self.assertEqual(output_dict[attr], val)