Ejemplo n.º 1
0
 def setup_class(self):
     mi = MobileInventory({
         'iPhone Model X': 100,
         'Xiaomi Model Y': 1000,
         'Nokia Model Z': 25
     })
     self.inventory = mi
Ejemplo n.º 2
0
 def setup_class(cls):
     cls.inventory = MobileInventory({
         'iPhone Model A': 50,
         'Xiaomi Model B': 2000,
         'Nokia Model C': 10,
         'Sony Model D': 1
     })
Ejemplo n.º 3
0
 def test_creating_inventory_with_negative_value(self):
     with pytest.raises(ValueError) as e:
         c6 = MobileInventory({
             'iPhone Model X': -45,
             'Xiaomi Model Y': 200,
             'Nokia Model Z': 25
         })
     assert str(e.value) == "No. of mobiles must be a positive integer"
Ejemplo n.º 4
0
 def test_creating_inventory_with_nonnumeric_values(self):
     with pytest.raises(ValueError) as e:
         c5 = MobileInventory({
             'iPhone Model X': '100',
             'Xiaomi Model Y': '1000',
             'Nokia Model Z': '25'
         })
     assert str(e.value) == "No. of mobiles must be a positive integer"
Ejemplo n.º 5
0
 def test_creating_inventory_with_numeric_keys(self):
     with pytest.raises(ValueError) as e:
         c4 = MobileInventory({
             1: 'iPhone Model X',
             2: 'Xiaomi Model Y',
             3: 'Nokia Model Z'
         })
     assert str(e.value) == "Mobile model name must be a string"
 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
Ejemplo n.º 7
0
 def test_creating_inventory_with_numeric_keys(self):
     with pytest.raises(ValueError) as err:
         mi = MobileInventory({
             1: 'iPhone Model X',
             2: 'Xiaomi Model Y',
             3: 'Nokia Model Z'
         })
         ex = err.exception
         ok_(ex.message, "Mobile model name must be a string")
Ejemplo n.º 8
0
 def test_creating_inventory_with_nonnumeric_values(self):
     with pytest.raises(ValueError) as err:
         mi = MobileInventory({
             'iPhone Model X': '100',
             'Xiaomi Model Y': '1000',
             'Nokia Model Z': '25'
         })
         ex = err.exception
         ok_(ex.message, "No. of mobiles must be a positive integer")
Ejemplo n.º 9
0
 def test_creating_inventory_with_negative_value(self):
     with pytest.raises(ValueError) as e:
         mi = MobileInventory({
             'iPhone Model X': -45,
             'Xiaomi Model Y': 200,
             'Nokia Model Z': 25
         })
         print("KP: ", e)
         ex = e.exception
         assert ex.message == "No. of mobiles must be a positive integer"
Ejemplo n.º 10
0
 def test_creating_specified_inventory(self):
     c2 = MobileInventory({
         'iPhone Model X': 100,
         'Xiaomi Model Y': 1000,
         'Nokia Model Z': 25
     })
     assert c2.balance_inventory == {
         'iPhone Model X': 100,
         'Xiaomi Model Y': 1000,
         'Nokia Model Z': 25
     }
Ejemplo n.º 11
0
 def test_creating_empty_inventory(self):
     mi = MobileInventory()
     assert mi.balance_inventory == {}
Ejemplo n.º 12
0
 def setup_class(cls):
     global inventory
     inventory = MobileInventory({'iPhone Model X':100, 'Xiaomi Model Y': 1000, 'Nokia Model Z':25})
Ejemplo n.º 13
0
 def test_creating_inventory_with_negative_value(self):
     with pytest.raises(ValueError):
         mi = MobileInventory({'iPhone Model X':-45, 'Xiaomi Model Y': 200, 'Nokia Model Z':25})
Ejemplo n.º 14
0
 def test_creating_inventory_with_nonnumeric_values(self):
     with pytest.raises(ValueError):
         mi = MobileInventory({'iPhone Model X':'100', 'Xiaomi Model Y': '1000', 'Nokia Model Z':'25'})
Ejemplo n.º 15
0
 def test_creating_inventory_with_numeric_keys(self):
     with pytest.raises(ValueError):
         mi = MobileInventory({1:'iPhone Model X', 2:'Xiaomi Model Y', 3:'Nokia Model Z'})
Ejemplo n.º 16
0
 def test_creating_inventory_with_list(self):
     with pytest.raises(TypeError):
         mi = MobileInventory(['iPhone Model X', 'Xiaomi Model Y', 'Nokia Model Z'])
Ejemplo n.º 17
0
 def test_creating_inventory_with_list(self):
     #c3 = MobileInventory(['iPhone Model X', 'Xiaomi Model Y', 'Nokia Model Z'])
     with pytest.raises(TypeError) as e:
         c3 = MobileInventory(
             ['iPhone Model X', 'Xiaomi Model Y', 'Nokia Model Z'])
     assert str(e.value) == "Input inventory must be a dictionary"
Ejemplo n.º 18
0
 def test_creating_inventory_with_list(self):
     with pytest.raises(TypeError) as err:
         mi = MobileInventory(
             ['iPhone Model X', 'Xiaomi Model Y', 'Nokia Model Z'])
         ex = err.exception
         ok_(ex.message, "Input inventory must be a dictionary")
Ejemplo n.º 19
0
 def test_creating_specified_inventory(self):
     mi = MobileInventory({
         'iPhone Model X': 100,
         'Xiaomi Model Y': 1000,
         'Nokia Model Z': 25
     })