def test_printout(self):
        """ Test that inventory_report prints correctly """
        import sys
        from io import StringIO
        from unittest.mock import patch

        with patch('sys.stdout', new=StringIO()) as output:
            items = generate_products()
            inventory_report(items)
            self.assertIn("ACME CORPORATION OFFICIAL INVENTORY REPORT",
                          output.getvalue().strip())
 def test_legal_names(self):
     """Test product naming convention."""
     report = inventory_report()
     product_names = report.combinednamelist
     adj_list = ADJECTIVES()
     noun_list = NOUNS()
     random_prod_selection = random.choice(product_names)
     self.assertIN(adj_list, random_prod_selection)
     self.assertIN(noun_list, random_prod_selection)
     self.assertIN(" ", random_prod_selection)
    def test_legal_names(self):
        names = inventory_report(generate_products())[0]
        count = 0
        for name in names:
            if name in legal_names:
                count += 1
            else:
                continue

        self.assertEqual(count, len(names))
Beispiel #4
0
 def test_legal_names(self):
     test_names = inventory_report(generate_products())
     test_names_adjectives = []
     test_names_nouns = []
     for name in test_names:
         test_names_adjectives.append(name.split(' ')[0])
         test_names_nouns.append(name.split(' ')[1])
     for adj in test_names_adjectives:
         self.assertTrue(adj in ADJECTIVES)
     for nn in test_names_nouns:
         self.assertTrue(nn in NOUNS)
 def test_default_num_products(self):
     a, b, c, d, length = inventory_report(generate_products())
     self.assertEqual(length, 30)
 def test_default_num_products(self):
     """Test default number of product report is 30."""
     report = inventory_report()
     self.assertEqual(self.report.number_of_products, 30)
Beispiel #7
0
from acme import BoxingGlove
from acme_report import generate_products, inventory_report

prod = Product('A Cool Toy')

glove = BoxingGlove('a glove')

print(prod.name)

print(prod.price)

print(prod.weight)

print(prod.flammability)

print(prod.identifier)

print(prod.stealability())

print(prod.explode())

print(glove.price)

print(glove.weight)

print(glove.punch())

print(glove.explode())

print(inventory_report(generate_products()))
    def test_default_num_products(self):
        products = generate_products(30)
        report = inventory_report(products)

        self.assertEqual(len(report['products']), 30)
 def test_default_num_products(self):
     """Test check to see if report returns 30 items"""
     names = inventory_report(generate_products())[0]
     self.assertEqual(len(names), 30)