Пример #1
0
 def setup_class(self):
     mi = MobileInventory({
         'iPhone Model A': 50,
         'Xiaomi Model B': 2000,
         'Nokia Model C': 10,
         'Sony Model D': 1
     })
     self.inventory = mi
Пример #2
0
 def test_creating_inventory_with_negative_value(self):
     with pytest.raises(ValueError) as error:
         mi = MobileInventory({
             'iPhone Model X': -45,
             'Xiaomi Model Y': 1000,
             'Nokia Model Z': 25
         })
         ex = error.exception
         assert ex.message == "No. of mobiles must be a positive integer"
Пример #3
0
 def test_creating_inventory_with_numeric_keys(self):
     with pytest.raises(ValueError) as error:
         mi = MobileInventory({
             1: 'iPhone Model X',
             2: 'Xiaomi Model Y',
             3: 'Nokia Model Z'
         })
         ex = error.exception
         assert ex.message == "Mobile model name must be a string"
Пример #4
0
 def setup_class(cls):
     cls.inventory = MobileInventory({
         'iPhone Model X': 100,
         'Xiaomi Model Y': 1000,
         'Nokia Model Z': 25
     })
Пример #5
0
    def test_creating_empty_inventory(self):
        i1 = MobileInventory()

        assert i1.balance_inventory == {}
Пример #6
0
 def test_creating_inventory_with_list(self):
     with pytest.raises(TypeError) as error:
         mi = MobileInventory(
             ['iPhone Model X', 'Xiaomi Model Y', 'Nokia Model Z'])
         ex = error.exception
         assert ex.message == "Input inventory must be a dictionary"
Пример #7
0
 def test_creating_specified_inventory(self):
     mi = MobileInventory({
         'iPhone Model X': 100,
         'Xiaomi Model Y': 1000,
         'Nokia Model Z': 25
     })