def validate_params(self):
        UserUtil.verified_phone_and_email(self.event)
        if not self.event.get('body'):
            raise ValidationError('Request parameter is required')

        validate(self.params, self.get_schema())
        DBUtil.validate_write_blacklisted(
            self.dynamodb,
            self.event['requestContext']['authorizer']['claims']['cognito:username']
        )
        DBUtil.validate_article_existence(self.dynamodb, self.params['article_id'], status='public')
        DBUtil.validate_parent_comment_existence(self.dynamodb, self.params['parent_id'])
        DBUtil.validate_user_existence(self.dynamodb, self.params['replyed_user_id'])
        DBUtil.validate_user_existence_in_thread(self.dynamodb, self.params['replyed_user_id'], self.params['parent_id'])
Ejemplo n.º 2
0
 def test_validate_parent_comment_existence_ng_with_child_comment(self):
     with self.assertRaises(RecordNotFoundError):
         DBUtil.validate_parent_comment_existence(
             self.dynamodb, self.comment_items[1]['comment_id'])
Ejemplo n.º 3
0
 def test_validate_parent_comment_existence_ng_not_exists_comment_id(self):
     with self.assertRaises(RecordNotFoundError):
         DBUtil.validate_parent_comment_existence(self.dynamodb, 'piyopiyo')
Ejemplo n.º 4
0
 def test_validate_parent_comment_existence_ok(self):
     result = DBUtil.validate_parent_comment_existence(
         self.dynamodb, self.comment_items[0]['comment_id'])
     self.assertTrue(result)