예제 #1
0
    def setUp(self):
        self.tv_code = 24332
        self.table_code = 89773
        self.lamp_code = 7346

        self.tv = ElectricAppliances(self.tv_code, 'Samsung TV', 1200.00,
                                     125.00, 'Samsung', 120)
        self.table = Furniture(self.table_code, 'Coffee Table', 300.00, 125.00,
                               'Glass', 'L')
        self.lamp = ElectricAppliances(self.lamp_code, 'Bed side lamp', 20.00,
                                       23.00, 'Target', 9)
예제 #2
0
 def test_create_electrical_appliance_item(cls):
     """ Create an electrical appliance instance and make sure it is initialized correctly """
     appliance = ElectricAppliances('VCR', 'What you walch Betamax on', 3,
                                    0, 'Panasonic', 120)
     item_dict = appliance.return_as_dictionary()
     assert item_dict['productCode'] == 'VCR'
     assert item_dict['description'] == 'What you walch Betamax on'
     assert item_dict['marketPrice'] == 3
     assert item_dict['rentalPrice'] == 0
     assert item_dict['Brand'] == 'Panasonic'
     assert item_dict['Voltage'] == 120
 def test_electric_appliances(self):
     appliance = ElectricAppliances("A", "B", "C", "D", "E", "F")
     self.assertDictEqual(appliance.return_as_dictionary(),
         {
             'product_code': "A",
             'description': "B",
             'market_price': "C",
             'rental_price': "D",
             'brand': "E",
             'voltage': "F",
         }
     )
예제 #4
0
    def test_electricappliances(self):
        """ Test creation of an ElectriAppliances item """

        electric_appliance = ElectricAppliances(2, 'Dummy Description', 100,
                                                10, 'Samsung', 120)

        self.assertEqual(
            {
                'product_code': 2,
                'description': 'Dummy Description',
                'market_price': 100,
                'rental_price': 10,
                'brand': 'Samsung',
                'voltage': 120
            }, electric_appliance.return_as_dictionary())
예제 #5
0
    def test_electric_appliance_return_as_dictionary(self):
        # Given
        args = {
            "product_code": "Test1234",
            "description": "Test Toaster",
            "market_price": 123.45,
            "rental_price": 10.20,
            "brand": "Testola",
            "voltage": 220,
        }

        # When
        self.ea = ElectricAppliances(**args)

        # Then
        self.assertEqual(args, self.ea.return_as_dictionary())
예제 #6
0
def add_new_item():
    """
    Adds a new item to the inventory of all items
    based on the object type.
    """
    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")
예제 #7
0
 def test_init_electric(self):
     microwave = ElectricAppliances(3, "silver_microwave", 50, 10, "Samsung", 110)
     self.assertEqual(3, microwave.product_code)
     self.assertEqual("silver_microwave", microwave.description)
     self.assertEqual(50, microwave.market_price)
     self.assertEqual(10, microwave.rental_price)
     self.assertEqual("Samsung", microwave.brand)
     self.assertEqual(110, microwave.voltage)
예제 #8
0
class ElectricAppliancesTests(TestCase):
    def setUp(self):
        self.microwave = ElectricAppliances(1573, 'Samsung Microwave', 120.00,
                                            125.00, 'Samsung', 120)

    def test_create_appliance(self):
        self.assertEqual(self.microwave.product_code, 1573)
        self.assertEqual(self.microwave.description, 'Samsung Microwave')
        self.assertEqual(self.microwave.market_price, 120.00)
        self.assertEqual(self.microwave.rental_price, 125.00)
        self.assertEqual(self.microwave.brand, 'Samsung')
        self.assertEqual(self.microwave.voltage, 120)

    def test_appliance_dict(self):
        self.assertEqual(
            self.microwave.return_as_dictionary().get('product_code'), 1573)
        self.assertEqual(
            self.microwave.return_as_dictionary().get('description'),
            'Samsung Microwave')
        self.assertEqual(
            self.microwave.return_as_dictionary().get('market_price'), 120.00)
        self.assertEqual(
            self.microwave.return_as_dictionary().get('rental_price'), 125.00)
        self.assertEqual(self.microwave.return_as_dictionary().get('brand'),
                         'Samsung')
        self.assertEqual(self.microwave.return_as_dictionary().get('voltage'),
                         120)
예제 #9
0
    def test_module(self):
        rug = Inventory(7, "oriental_rug", 30, 5)
        rug_info = rug.return_as_dictionary()

        sofa = Furniture(5, "brown_sofa", 100, 20, "leather", "large")
        sofa_info = sofa.return_as_dictionary()

        tv = ElectricAppliances(6, "4k_tv", 2000, 50, "Panasonic", 220)
        tv_info = tv.return_as_dictionary()

        price = get_latest_price(8)

        self.assertEqual(7, rug.product_code)
        self.assertEqual("oriental_rug", rug_info["description"])

        self.assertEqual("brown_sofa", sofa.description)
        self.assertEqual(100, sofa_info["market_price"])

        self.assertEqual(2000, tv.market_price)
        self.assertEqual(50, tv_info["rental_price"])

        self.assertEqual(24, get_latest_price(1))
예제 #10
0
class FurnitureTest(TestCase):
    def test_furniture_init(self):
        # Given
        args = {
            "product_code": "Test5678",
            "description": "Test Sofa",
            "market_price": 123.45,
            "rental_price": 10.20,
            "material": "Flubber",
            "size": "Triple Single",
        }

        # When
        self.furniture = Furniture(**args)

        # Then
        self.assertEqual(123.45, self.furniture.market_price)
        self.assertEqual("Flubber", self.furniture.material)
        self.assertEqual("Triple Single", self.furniture.size)

    def test_furniture_return_as_dictionary(self):
        # Given
        args = {
            "product_code": "Test1234",
            "description": "Test Toaster",
            "market_price": 123.45,
            "rental_price": 10.20,
            "brand": "Testola",
            "voltage": 220,
        }

        # When
        self.ea = ElectricAppliances(**args)

        # Then
        self.assertEqual(args, self.ea.return_as_dictionary())
예제 #11
0
 def setUp(self):
     self.microwave = ElectricAppliances(1573, 'Samsung Microwave', 120.00,
                                         125.00, 'Samsung', 120)
예제 #12
0
 def test_return_as_dict_electric(self):
     microwave = ElectricAppliances(3, "silver_microwave", 50, 10, "Samsung", 110)
     my_dict = {"product_code": 3, "description": "silver_microwave", "market_price": 50, "rental_price": 10,
                "brand": "Samsung", "voltage": 110}
     self.assertEqual(my_dict, microwave.return_as_dictionary())