Ejemplo n.º 1
0
 def assert_proportions(self, recipes):
     """The tests in this class are designed so that the results are the
        same for each tests despite the inputs being different. This allows
        us to test for correctness with just one method (this one)"""
     ingredients, columns = parse_file_contents(recipes)
     new_columns = normalize(ingredients, columns)
     self.assertAlmostEquals(new_columns[0][0], 30.96, 2)
     self.assertAlmostEquals(new_columns[0][1], 46.860, 2)
     self.assertAlmostEquals(new_columns[1][0], 31.38, 2)
     self.assertAlmostEquals(new_columns[1][1], 26.57, 2)
    def test_three_rows_to_grams(self):
        """Convert three rows of mixed weight and volume measures to grams"""
        ingredients = (FLOUR, SUGAR, BUTTER)
        flour = ((7, OZ), (200, GRAM), (1, ML))
        sugar = ((1, METRIC_CUP), (4, OZ), (1, ML))
        butter = ((1, METRIC_CUP), (4, OZ), (1, ML))
        columns = zip(flour, sugar, butter)
        new_columns = normalize(ingredients, columns)
        
        self.assertEquals(len(new_columns), 3)
        self.assertEquals(len(new_columns[0]), 3)

        self.assertAlmostEquals(new_columns[0][1], 46.86, 2)
        self.assertAlmostEquals(new_columns[1][1], 26.569, 2)
        self.assertAlmostEquals(new_columns[2][1], 26.569, 2)