def test_product_methods(self): prod = Product('Test Product', weight=100, price=30, flammability=2) self.assertEqual(prod.stealability(), 'Very stealable!') self.assertEqual(prod.explode(), '...BABOOM!!')
def test_product_methods(self): """Test the stealability() and explode() methods' results.""" prod = Product(name='Test Product', price=3, weight=40, flammability=2) self.assertEqual(prod.stealability(), 'Not so stealable...') self.assertEqual(prod.explode(), '...BABOOM!!')
def test_default_product_identifier(self): """Test default product price being 10.""" prod = Product('Test Product') self.assertEqual(prod.identifier, 4504056)
def test_stealability(self): '''Test stealability when product price is 30.''' pro = Product(price=30) self.assertEqual(pro.stealability(), 'Very Stealable')
def setUp(self): """Set's up the tests methods""" self.product = Product('Test Product')
def test_product_stealability(self): """Test product stealability""" prod = Product('Test Product', price=10, weight=20) self.assertEqual(prod.stealability(), "Kinda stealable.")
def test_default_steal_explode(self): """Test default stealability and explode""" prod = Product('Test Product 2') self.assertEqual(prod.stealability(), 'Kinda stealable...') self.assertEqual(prod.explode(), '...fizzle.')
def test_functions(self): """Test explosion and stealibility""" prod = Product('Test 2', 20, 20, 3) self.assertEqual(prod.explode(), '...BABOOM!!') self.assertEqual(prod.stealability(), 'Very stealable.')
def test_default_product_price(): """Test default product price being 10.""" prod = Product('Test Product') assert prod.price == 10
def test_default_product_name(self): """Test default product weight being 20.""" prod = Product('Test Product') #this is producing a strange result... self.assertTrue(prod.name, "Tom")
def test_default_product_weight(self): """Ensures the default weight is 20""" prod = Product('Test Product') self.assertEqual(prod.weight, 20)
def test_default_product_price(self): prod = Product('Test Product') self.assertEqual(prod.price, 10)
def test_default_flam(self): prod = Product('Test Product') self.assertEqual(prod.flammability, 0.5)
def test_default_product_flam(self): """Test default product price being 10.""" prod = Product('Test Product') self.assertEqual(prod.flammability, 0.5)
def test_product_weight(self): """Test new product weight being 20.""" prod = Product('Test Product') self.assertEqual(prod.weight, 20)
def test_default_product_weight(): """Test default product weight being 20.""" prod = Product('Test Product') assert prod.weight == 20
def test_product_flammability(self): """Test default product flammability being 0.5.""" prod = Product('Test Product') self.assertEqual(prod.flammability, 0.5)
def test_product_with_diff_values(): """Test product methods by passing different values as attributes""" prod = Product('Test Product', price=25, weight=25, flammability=1.2) assert prod.stealability() == 'Very Stealable!' assert prod.explode() == '...boom!'
def test_product_explode(self): """Test product explodity""" prod = Product('Test Product', weight=20, flammability=500) self.assertEqual(prod.explode(), "...BABOOM!!")
def test_product_id(self): """Test product id is an integer""" prod = Product('Another Test') self.assertTrue(isinstance(prod.identifier, int))
def test_default_product_weight(self): '''Test default product weight is 20.''' prod = Product('Test Product') self.assertEqual(prod.weight, 20)
def test_steal(self): """Test the stealability function""" p = Product('DVD', 20, 1, 0.9) self.assertTrue(p.stealability(), 'Very stealable!')
def test_default_product_price(self): '''Test default product price is 10.''' prod = Product('Test Product') self.assertEqual(prod.price, 10)
def test_explode(self): """Test the explode function""" p = Product('DVD', 20, 1, 0.9) self.assertTrue(p.explode(), '...fizzle')
def test_default_product_weight(self): """test default prod weight being 20""" prod = Product('Test') self.assertEqual(prod.weight, 20)
prods = generate_products() for prod in prods: name_split = prod.name.split(" ") self.assertIn(name_split[0], RAND_ADJ) self.assertIn(name_split[1], RAND_NOUN) if __name__ == "__main__": unittest.main() name = f"{choice(RAND_ADJ)} {choice(RAND_NOUN)}" price = randint(PRICEWEIGHT_RANGE[0], PRICEWEIGHT_RANGE[1]) weight = randint(PRICEWEIGHT_RANGE[0], PRICEWEIGHT_RANGE[1]) flam = uniform(FLAMMABILITY_RANGE[0], FLAMMABILITY_RANGE[1]) products.append(Product(name=name, weight=weight, price=price, flammability=flam)) return products def inventory_report(products): """Get a report on an inventory""" # Init vars avg_price = 0 avg_weight = 0 avg_flam = 0 unique_names = [] # Loop through products for product in products: unique_names.append(product.name) avg_price += product.price
def test_default_product_weight(self): """Test default product price being 10.""" prod = Product('Test Product') self.assertEqual(prod.weight, 20)
def test_default_product_price(self): """Test default product price being 10.""" prod = Product("Test Product") self.assertEqual(prod.price, 10) self.assertEqual(prod.weight, 20) self.assertEqual(prod.flammability, 0.5)
def test_default_product_price(self): """Test default product price being 10.""" prod = Product('Test Product') self.assertEqual(prod.price, 10)
def test_default_product_weight(self): prod = Product('Test Product') self.assertEqual(prod.weight, 20)