def validate_params(self): UserUtil.verified_phone_and_email(self.event) # check price type is integer or decimal ParameterUtil.validate_price_params(self.params.get('price')) if self.params.get('price') is not None: self.params['price'] = int(self.params['price']) validate(self.params, self.get_schema()) if self.params.get('eye_catch_url'): TextSanitizer.validate_img_url(self.params.get('eye_catch_url')) if self.params.get('tags'): ParameterUtil.validate_array_unique(self.params['tags'], 'tags', case_insensitive=True) TagUtil.validate_format(self.params['tags']) DBUtil.validate_article_existence( self.dynamodb, self.params['article_id'], user_id=self.event['requestContext']['authorizer']['claims'] ['cognito:username'], status='public', version=2) DBUtil.validate_topic(self.dynamodb, self.params['topic']) DBUtil.validate_exists_title_and_body(self.dynamodb, self.params['article_id'])
def test_validate_exists_title_and_body_ok_ng_not_exists_body(self): with self.assertRaises(ValidationError): DBUtil.validate_exists_title_and_body(self.dynamodb, 'testid000003')
def test_validate_exists_title_and_body_ok(self): result = DBUtil.validate_exists_title_and_body(self.dynamodb, 'testid000001') self.assertTrue(result)