def test_ratio_difference_zero(self): """Test difference of two identical ratios""" ingredients, _ = test_data() ratio_1 = create_ratio(ingredients, [1, 2, 3]) ratio_2 = create_ratio(ingredients, [1, 2, 3]) difference, _ = percentage_difference(ratio_1, ratio_2) self.assertEquals(0, difference)
def test_ratio_difference(self): """Test per ingredient and over all percentage difference""" ingredients, _ = test_data() ratio_1 = create_ratio(ingredients, [1, 30, 100]) ratio_2 = create_ratio(ingredients, [1, 60, 50]) difference, differences = percentage_difference(ratio_1, ratio_2) self.assertAlmostEquals(0.496, difference, 2) self.assertAlmostEquals(differences[1][0], 0.81, 2) self.assertEquals(differences[1][1], EGG) self.assertAlmostEquals(differences[0][0], 0.17, 2) self.assertEquals(differences[0][1], FLOUR)