Exemplo n.º 1
0
    def test_eater_get_nutrition_hx(self):
        e = eater.Eater()
        e.put()
        # create nut rec with date of today and protein 0
        rec = eater.NutritionRecord(parent=e.key)
        rec.put()
        # create another with yesterday date and protein 1
        yesterday = datetime.datetime.now() - datetime.timedelta(days=1)
        rec_2 = eater.NutritionRecord(parent=e.key, date=yesterday, protein=1)
        rec_2.put()

        # Test days arg in query works
        self.assertEqual(1, len(e.get_nutrition_hx(1)))

        # Test returns both and order correct
        hx = e.get_nutrition_hx(3)
        self.assertEqual(2, len(hx))
        self.assertEqual(1, hx[1].protein)
Exemplo n.º 2
0
 def test_eater_get_remaining_nutrition(self):
     e = eater.Eater()
     e.nutrition_plans = [
         eater.NutritionPlan(protein=2, carb=4, fat=6, cals=78)
     ] * 7
     e.put()
     rec = eater.NutritionRecord(parent=e.key, protein=0, carb=1, fat=2)
     rec.put()
     nut = e.get_remaining_nutrition()
     self.assertEqual(2, nut['protein'])
     self.assertEqual(3, nut['carb'])
     self.assertEqual(4, nut['fat'])
     self.assertEqual(56, nut['cals'])
Exemplo n.º 3
0
    def test_eater_add_meal(self):
        e = eater.Eater()
        e.put()

        # Create nut record for today
        r = eater.NutritionRecord(parent=e.key, protein=10, carb=20, fat=30)
        r.put()

        e.add_meal(protein=1, carb=2, fat=3, sodium=4, fiber=5)
        self.assertEqual(11, r.protein)
        self.assertEqual(22, r.carb)
        self.assertEqual(33, r.fat)
        self.assertEqual(4, r.sodium)
        self.assertEqual(5, r.fiber)
Exemplo n.º 4
0
 def test_nutrition_record_insert(self):
     p = eater.NutritionRecord(protein=10, fat=10, carb=20)
     p.put()
     self.assertEqual(10, p.protein)
     # Check cals calc
     self.assertEqual(210, p.cals)