Beispiel #1
0
 def test_like_this_special_updated(self):
     result = controller.like_this('9fea3eccf63c5f65bea172060293be9f',
                                   self.test_sub, self.db)
     assert result is True
     specials = controller.get_special([datetime.date(2021, 4, 14)],
                                       self.db)
     assert specials.schedules[0].a_menu.like_count == 1
     assert specials.schedules[0].b_menu.like_count == 0
Beispiel #2
0
 def test_like_this_permanent_updated(self):
     result = controller.like_this(self.menu_ids[0], self.test_sub, self.db)
     assert result is True
     permanent = controller.all_permanent(self.db)
     for perm in permanent.menus:
         if perm.id == self.menu_ids[0]:
             assert perm.like_count == 1
         else:
             assert perm.like_count == 0
Beispiel #3
0
 def test_get_likes_by_sub_multiple_like(self):
     controller.like_this(self.menu_ids[0], self.test_sub, self.db)
     controller.like_this(self.menu_ids[1], self.test_sub, self.db)
     controller.like_this(self.menu_ids[2], self.test_sub, self.db)
     result = controller.get_likes_by_sub(self.test_sub, self.db)
     assert sorted(result) == sorted(
         [self.menu_ids[0], self.menu_ids[1], self.menu_ids[2]])
Beispiel #4
0
 def test_like_this(self):
     result = controller.like_this(self.menu_ids[0], self.test_sub, self.db)
     assert result is True
Beispiel #5
0
 def test_like_this_invalid_id(self):
     result = controller.like_this('this_is_invalid', self.test_sub,
                                   self.db)
     assert result is False
Beispiel #6
0
 def test_get_likes_by_sub_single_like(self):
     controller.like_this(self.menu_ids[0], self.test_sub, self.db)
     result = controller.get_likes_by_sub(self.test_sub, self.db)
     assert result == [self.menu_ids[0]]
Beispiel #7
0
 def test_like_this_duplication(self):
     controller.like_this(self.menu_ids[0], self.test_sub, self.db)
     result = controller.like_this(self.menu_ids[0], self.test_sub, self.db)
     assert result is False
Beispiel #8
0
async def like_post(req: LikePostRequest, db: Session = Depends(get_db)):
    success = like_this(req.menu_id, req.token, db)

    if not success:
        raise HTTPException(409)