Exemplo n.º 1
0
 def create_meal(self, **options):
     props = dict(
         owner_user_id=self.user.id,
         text="Greatest Meal Ever",
         entry_datetime=datetime.now().isoformat(),
         calorie_count=9001,
     )
     props.update(options)
     return Meal.create(**props)
Exemplo n.º 2
0
 def _create_meal(self, **overrides):
     params = {
         'owner_user_id': self.user.id,
         'text': "yummy yummy",
         'entry_datetime': '2018-11-25T09:00:00',
         'calorie_count': 400,
     }
     params.update(overrides)
     return Meal.create(**params)
Exemplo n.º 3
0
    def test_meal_create(self):
        DATETIME = datetime.now().replace(microsecond=0)
        meal = Meal.create(owner_user_id=self.user.id,
                           text="Greatest Meal Ever",
                           entry_datetime=DATETIME.isoformat(),
                           calorie_count=9001)

        meal = Meal.get_by_id(meal.id)

        eq_(meal.owner_user_id, self.user.id)
        eq_(meal.text, "Greatest Meal Ever")
        eq_(meal.entry_datetime, DATETIME)
        eq_(meal.entry_time, DATETIME.time())
        eq_(meal.entry_date, DATETIME.date())
        eq_(meal.calorie_count, 9001)
Exemplo n.º 4
0
    def post(self):
        # who are you?
        current_user = g.user

        params = request.get_json()

        if params is None:
            abort(400, message="invalid params")

        props = params['meal'].copy()
        props['calorie_count'] = props['calories']
        props['owner_user_id'] = current_user.id

        new_meal = Meal.create(**props)

        return new_meal