Пример #1
0
 def test_default_stealability(self):
     prod_a = Product('Test Product', price=9, weight=20)
     self.assertEqual(prod_a.stealability(), 'Not so stealable...')
     prod_b = Product('Test Product', price=10, weight=20)
     self.assertEqual(prod_b.stealability(), 'Kinda stealable')
     prod_c = Product('Test Product', price=11, weight=10)
     self.assertEqual(prod_c.stealability(), 'Very Stealable!')
Пример #2
0
    def test_stealability(self):
        '''test if stealability function works properly'''

        prod = Product('Test Product', price=5, weight=10)
        self.assertEqual(prod.stealability(), 'Kinda stealable.')
        prod2 = Product('Test Product', price=15, weight=10)
        self.assertEqual(prod2.stealability(), 'Very stealable!')
Пример #3
0
 def test_default_product_stealability(self):
     """Test stealability() returns the correct messages."""
     prod1 = Product('Test Product 1', price=5, weight=20)
     prod2 = Product('Test Product 2', price=15, weight=20)
     prod3 = Product('Test Product 3', price=25, weight=20)
     self.assertEqual(prod1.stealability(), 'Not so stealable...')
     self.assertEqual(prod2.stealability(), 'Kinda stealable.')
     self.assertEqual(prod3.stealability(), 'Very stealable!')
Пример #4
0
 def test_stealability(self):
     """Test stealability method"""
     prod = Product('Test Product', 5, 10)
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     prod.stealability()
     sys.stdout = sys.__stdout__
     self.assertEqual(capturedOutput.getvalue(), "Kinda stealable.\n")
Пример #5
0
    def test_stealability(self):
        prod = Product('Test product', 10, 20)
        prod2 = Product('Test product 2', 20, 20)
        prod3 = Product('Test product 3', 5, 20)

        self.assertEqual(prod.stealability(), 'Kinda stealable')
        self.assertEqual(prod2.stealability(), 'Very stealable!')
        self.assertEqual(prod3.stealability(), 'Not so stealable')
 def test_prodcut_stealability(self):
     """Test variety of product stealability case."""
     prod_01 = Product('Test Product')
     prod_02 = Product('Test Product', 1, 3)
     prod_03 = Product('Test Product', 1, 1)
     self.assertEqual(prod_01.stealability(), 'Kinda stealable.')
     self.assertEqual(prod_02.stealability(), 'Not so stealable...')
     self.assertEqual(prod_03.stealability(), 'Very stealable!')
Пример #7
0
 def test_theft(self):
     """Test all possible outcomes of stealability()"""
     stealy = Product("batteries", price=1, weight=1)
     self.assertEqual(stealy.stealability(), "Very stealable!")
     no_stealy = Product("big rock", price=1, weight=100)
     self.assertEqual(no_stealy.stealability(), "Not so stealable...")
     maybe_stealy = Product("The Orb", price=4, weight=5)
     self.assertEqual(maybe_stealy.stealability(), "Kinda stealable.")
Пример #8
0
 def test_stealability(self):
     '''tests the products stealability given some values for
     price and weight'''
     prod = Product('Test Product', weight=11, price=7)
     self.assertEqual(prod.stealability(), 'Kinda stealable')
     prod2 = Product('Test Product', weight=11, price=5)
     self.assertEqual(prod2.stealability(), 'Not so stealable...')
     prod3 = Product('Test Product', weight=1, price=11)
     self.assertEqual(prod3.stealability(), 'Very stealable')
Пример #9
0
 def test_steability(self):
     steal1 = Product('steal1', 10, 20)
     steal2 = Product('steal2', 5, 20)
     steal3 = Product('steal3', 20, 20)
     steal4 = Product('steal4', 21, 20)
     
     self.assertEqual(steal1.stealability(), "Kinda stealable.")
     self.assertEqual(steal2.stealability(), "Not so stealable...")
     self.assertEqual(steal3.stealability(), "Very stealable!")
     self.assertEqual(steal4.stealability(), "Very stealable!")
Пример #10
0
 def test_default_product_stealability(self):
     """Test default stealability ratio over 1.0 """
     prod1 = Product('Test Product', price=14, weight=30)
     self.assertEqual(prod1.stealability(), "Not so stealable...")
     prod2 = Product('Test Product', price=15, weight=30)
     self.assertEqual(prod2.stealability(), "Kinda stealable")
     prod3 = Product('Test Product', price=15, weight=15)
     self.assertEqual(prod3.stealability(), "Kinda stealable")
     prod4 = Product('Test Product', price=16, weight=15)
     self.assertEqual(prod4.stealability(), "Very stealable!")
    def test_stealability(self):
        p1 = Product('prod1')
        p2 = Product('prod2', 5, 20)
        p3 = Product('prod3', 20, 20)
        p4 = Product('prod4', 25, 20)

        self.assertEqual(p1.stealability(), "Kinda stealable.")
        self.assertEqual(p2.stealability(), "Not so stealable...")
        self.assertEqual(p3.stealability(), "Very stealable!")
        self.assertEqual(p4.stealability(), "Very stealable!")
Пример #12
0
 def test_different_vales(self):
     """test the product with change"""
     prod = Product('Test Product')
     self.assertEqual(prod.stealability(),
                      'Kinda stealable')  #added for stea.
     self.assertEqual(prod.explode(), '...boom!')  #added for explode
     #setting up a test for different values
     prod = Product("test 2", price=15, weight=6)
     self.assertEqual(prod.stealability(), 'Very stealable!')
     self.assertEqual(prod.explode(), '...fizzle')
 def test_actions(self):
     """Test actions done to various product"""
     prod = Product("Test Product")
     self.assertEqual(prod.stealability(), "Kinda stealable.")
     self.assertEqual(prod.explode(), "...boom!")
     prod = Product("Test Product", price=10, weight=10, flammability=5)
     self.assertEqual(prod.stealability(), "Very stealable!")
     self.assertEqual(prod.explode(), "...BABOOM!!")
     prod = Product("Test Product", price=1, weight=20, flammability=0)
     self.assertEqual(prod.stealability(), "Not so stealable...")
     self.assertEqual(prod.explode(), "...fizzle.")
Пример #14
0
 def test_range_stealability(self):
     test_price = random.randrange(0, 100)
     test_weight_high = test_price / 3
     test_weight_low = test_price * 3
     prod_high = Product(name='Test Product',
                         price=test_price,
                         weight=test_weight_high)
     prod_low = Product(name='Test Product',
                        price=test_price,
                        weight=test_weight_low)
     self.assertEqual(prod_high.stealability(), "Very stealable!")
     self.assertEqual(prod_low.stealability(), "Kinda stealable.")
Пример #15
0
    def test_stealability(self):
        '''situation where stealability should print not so stealable'''
        the_moon = Product(price=10, weight=200)
        self.assertEqual(the_moon.stealability(), 'not so stealable...')

        '''situation where stealability should print kinda stealable'''
        bunny = Product(price=10, weight=20)
        self.assertEqual(bunny.stealability(), 'kinda stealable')

        '''situation where stealability should print very stealable'''
        blueprints = Product(price=20, weight=10)
        self.assertEqual(blueprints.stealability(), 'very stealable!')
    def test_stealability_and_explode(self):
        """Test stealability and explode with non-default inputs"""
        prod_low = Product('low', price=1, weight=4, flammability=1)
        self.assertEqual(prod_low.stealability(), "Not so stealable...")
        self.assertEqual(prod_low.explode(), "...fizzle.")

        prod_med = Product('med', price=2, weight=4, flammability=3)
        self.assertEqual(prod_med.stealability(), "Kinda stealable.")
        self.assertEqual(prod_med.explode(), "...boom!")

        prod_high = Product('high', price=4, weight=4, flammability=15)
        self.assertEqual(prod_high.stealability(), "Very stealable!")
        self.assertEqual(prod_high.explode(), "...BABOOM!!")
    def test_stealability_and_explode(self):
        """Test stealability and explode with non-default inputs"""
        prod_low = Product('low_risk', price=1, weight=4, flammability=1)
        self.assertEqual(prod_low.stealability(), 'Not so stealable...')
        self.assertEqual(prod_low.explode(), '...fizzle.')

        prod_med = Product('med_risk', price=3, weight=4, flammability=3)
        self.assertEqual(prod_med.stealability(), 'Kinda stealable.')
        self.assertEqual(prod_med.explode(), '...boom!')

        prod_high = Product('high_risk', price=5, weight=4, flammability=20)
        self.assertEqual(prod_high.stealability(), 'Very stealable!')
        self.assertEqual(prod_high.explode(), '...BABOOM!')
    def test_default_product_stealabilityweight(self):
        prod = Product('Test Product')
        prod.price = 100
        prod.weight = 201
        self.assertEqual(prod.stealability(), 'Not so stealable...')

        prod = Product('Test Product')
        prod.price = 100
        prod.weight = 200
        self.assertEqual(prod.stealability(), 'Kinda stealable')

        prod = Product('Test Product')
        prod.price = 100
        prod.weight = 100
        self.assertEqual(prod.stealability(), 'Very stealable!')
Пример #19
0
 def test_stealable_and_explode(self):
     bomb = Product('Explosive')
     bomb.price = 200
     bomb.weight = 30
     bomb.flammability = 2.5
     self.assertEqual(bomb.stealability(), 'Very stealable!')
     self.assertEqual(bomb.explode(), '...BABOOM!!')
def generate_products(number_of_products=30):
    """
    Generates the product data entries for n number of products.

    Parameters
    ----------
    number_of_products: int
        An interger indicating the number of products to create.

    Returns
    ---------
    generated_products: list
        A list of each Product's attributes in sub-lists.
    """
    generated_products = []
    adjs = ADJECTIVES
    nouns = NOUNS
    for i in range(number_of_products):
        p_createdid = i
        p_name = random.choice(adjs) + " " + random.choice(nouns)
        p_price = random.randint(5, 100)
        p_weight = random.randint(5, 100)
        p_flammability = random.uniform(0.0, 2.5)
        prod = Product(name=p_name, price=p_price, weight=p_weight,
                       flammability=p_flammability)
        theftable = prod.stealability()
        generated_products.append([p_name, p_price, p_weight, p_flammability,
                                   theftable, p_createdid])
    return generated_products
Пример #21
0
 def test_stealability_and_explosiveness(self):
     prod = Product('Nuclear Weapon',
                    price=1,
                    weight=1000,
                    flammability=1000000)
     self.assertEqual(prod.stealability(), 'Not so stealable...')
     self.assertEqual(prod.explode(), '...BABOOM!!')
 def test_stealable(self):
     """Test for .stealability in acme.py file"""
     prod = Product(name='Test Product',
                    weight=100,
                    price=1,
                    flammability=0.5)
     self.assertEqual(prod.stealability(), "Not so stealable...")
Пример #23
0
 def test_stealability_explode(self):
     prod = Product(name='Test Product',
                    price=100,
                    weight=100,
                    flammability=100)
     self.assertEqual(prod.stealability(), "Kinda stealable."),
     self.assertEqual(prod.explode(), "...it's a glove.")
Пример #24
0
 def test_unique_product_stealability(self):
     """Test a unique products stealability method"""
     prod = Product('Test Product', 100, 2000, 2)
     # price * weight = stealability
     # 100 / 2000 = .05
     # stealability() should return "Not so stealable..."
     self.assertEqual(prod.stealability(), "Not so stealable...")
Пример #25
0
    def test_stealability(self):
        """Test if our theft alert metric is viable."""
        p = 50
        w = 100

        prod = Product('Test Product', price=p, weight=w)
        self.assertEqual(prod.stealability(), 'Kinda stealable.')
Пример #26
0
 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_default_prodct(self):
     """test all attributes and methods of default product"""
     prod = Product("default")
     self.assertEqual(prod.price, 10)
     self.assertAlmostEqual(prod.flammability, 0.5)
     self.assertEqual(prod.weight, 20)
     self.assertEqual(prod.stealability(), "Kinda stealable.")
Пример #28
0
class AcmeProductTests(unittest.TestCase):
    """Making sure Acme products are the tops!"""
    def setUp(self):
        '''make the Product to use for testing'''
        self.test_prod = Product('Anvil',
                                 price=150,
                                 weight=2500,
                                 flammability=0.001)

    def test_default_product_price(self):
        """Test default product price being 10."""
        prod = Product('Test Product')
        self.assertEqual(prod.price, 10)

    def test_default_attributes(self):
        '''test all default attributes'''
        prod = Product('Foobar')
        self.assertEqual(prod.price, 10)
        self.assertEqual(prod.weight, 20)
        self.assertEqual(prod.flammability, 0.5)

    def test_methods(self):
        '''test stealability and explode methods'''
        self.assertEqual(self.test_prod.stealability(), 'Not so stealable...')
        self.assertEqual(self.test_prod.explode(), '..fizzle.')
 def test_default_stealability_and_explosive_quality(self):
     """ Test default product stealability and explosive quality"""
     prod = Product('Test Product')
     stealable = prod.stealability()
     explosive = prod.explode()
     self.assertEqual(stealable, 'Kinda stealable')
     self.assertEqual(explosive, '...boom!')
 def test_nondefault_stealability_explode(self):
     """Test stealability and explode functions of non-default Products"""
     prod = Product('Test Product')
     prod.price = 20
     prod.weight = 10
     prod.flammability = 1
     self.assertEqual(prod.stealability(), "Very stealable!")
     self.assertEqual(prod.explode(), "...boom!")