Esempio n. 1
0
 def test_not_in_item_info(self):
     """ testing return value of item info """
     inventory_input = ['1', 'Frame', 25, 'N', 'N', '2']
     expected = 'Item not found in inventory\n'
     with patch('builtins.input', side_effect=inventory_input):
         main.addnewitem()
         with patch('sys.stdout', new=io.StringIO()) as print_out:
             main.iteminfo()
             self.assertEqual(print_out.getvalue(), expected)
Esempio n. 2
0
 def test_item_info(self):
     """ testing return value of item info """
     inventory_input = ['1', 'Frame', 25, 'N', 'N', '1']
     expected = 'productCode:1\ndescription:Frame\nmarketPrice:24\nrentalPrice:25\n'
     with patch('builtins.input', side_effect=inventory_input):
         main.addnewitem()
         with patch('sys.stdout', new=io.StringIO()) as print_out:
             main.iteminfo()
             self.assertEqual(print_out.getvalue(), expected)
Esempio n. 3
0
 def test_iteminfo(self):
     '''
     method doc string
     '''
     # pylint: disable=E1111
     with patch('builtins.input', return_value='test1'):
         test_ii = mm.iteminfo()
     with patch('builtins.input', return_value='test2'):
         input_ii = mm.iteminfo()
     self.assertEqual(test_ii, input_ii)
 def test_iteminfo(self):
     main.FULL_INVENTORY = {"2":{"productcode":2}}
     with patch("builtins.input", side_effect="2"):
         with patch("sys.stdout", new_callable=io.StringIO) as value:
             main.iteminfo()
             self.assertEqual(value.getvalue(), "productcode:2\n")
     with patch("builtins.input", side_effect="Error_time"):
         with patch("sys.stdout", new_callable=io.StringIO) as value:
             main.iteminfo()
             self.assertEqual(value.getvalue(), "Item not found in inventory\n")
Esempio n. 5
0
    def test_inventory_integration(self):
        ''' Function to test integration of inventory management '''
        inventory_input = ['1', 'Frame', 25, 'N', 'N']
        appliance_input = ['2', 'Toaster', 25, 'N', 'Y', 'LG', '220V']
        furniture_input = ['3', 'Chair', 25, 'Y', 'WOOD', 'XL']
        expected_app = {'productCode': '2', 'description': 'Toaster', 'marketPrice': 24,
                        'rentalPrice': 25, 'brand': 'LG', 'voltage': '220V'}
        expected_furn = {'productCode': '3', 'description': 'Chair', 'marketPrice': 24,
                         'rentalPrice': 25, 'material': 'WOOD', 'size': 'XL'}
        expected_inv = {'productCode': '1', 'description': 'Frame',
                        'marketPrice': 24, 'rentalPrice': 25}
        full_inventory = {'1': {'productCode': '1', 'description': 'Frame',
                                'marketPrice': 24, 'rentalPrice': 25},
                          '2': {'productCode': '2',
                                'brand': 'LG', 'description': 'Toaster',
                                'marketPrice': 24,
                                'rentalPrice': 25, 'voltage': '220V'},
                          '3': {'productCode': '3',
                                'description': 'Chair',
                                'marketPrice': 24, 'rentalPrice': 25,
                                'material': 'WOOD', 'size': 'XL'}}

        with patch('builtins.input', side_effect=inventory_input):
            main.addnewitem()
        with patch('builtins.input', side_effect=appliance_input):
            main.addnewitem()
        with patch('builtins.input', side_effect=furniture_input):
            main.addnewitem()
        self.assertEqual(main.FULLINVENTORY['3'], expected_furn)
        self.assertEqual(main.FULLINVENTORY['2'], expected_app)
        self.assertEqual(main.FULLINVENTORY['1'], expected_inv)
        with patch('builtins.input', side_effect=['4', '1']):
            with patch('sys.stdout', new=io.StringIO()) as print_out:
                main.iteminfo()
                self.assertEqual(print_out.getvalue(),
                                 'Item not found in inventory\n')
            with patch('sys.stdout', new=io.StringIO()) as print_out:
                main.iteminfo()
                self.assertEqual(print_out.getvalue(),
                                 'productCode:1\ndescription:Frame\nmarketPrice:24\nrentalPrice:25\n')
        self.assertEqual(main.FULLINVENTORY, full_inventory)
        with patch('sys.stdout', new=io.StringIO()) as print_out:
            main.getprice()
            self.assertEqual(print_out.getvalue(), 'Get price\n')