def test_validate_array_unique_with_not_unique_case_insensitive(self): target_items = ["FOO", "BAR", "foo"] with self.assertRaises(ValidationError): ParameterUtil.validate_array_unique(target_items, 'tags', case_insensitive=True)
def test_validate_array_unique_ok(self): target_items = ["FOO", "BAR", "foo"] try: ParameterUtil.validate_array_unique(target_items, 'tags') except ValidationError: self.fail('expected no error is raised')
def test_validate_array_unique_ok_with_case_insensitive(self): target_items = ["FOO", "BAR", "BAZ"] try: ParameterUtil.validate_array_unique(target_items, 'tags', case_insensitive=True) except ValidationError: self.fail('expected no error is raised')
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 validate_params(self): validate(self.params, self.get_schema()) 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='draft') DBUtil.validate_topic(self.dynamodb, self.params['topic'])
def validate_params(self): if self.event.get('pathParameters') is None: raise ValidationError('pathParameters is required') validate(self.params, self.get_schema()) 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' ) DBUtil.validate_topic(self.dynamodb, self.params['topic'])
def validate_params(self): UserUtil.verified_phone_and_email(self.event) if self.event['requestContext']['authorizer']['claims'].get( 'custom:private_eth_address') is None: raise ValidationError('not exists private_eth_address') validate(self.params, self.get_schema()) 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='draft') DBUtil.validate_topic(self.dynamodb, self.params['topic'])
def test_validate_array_unique_with_not_unique(self): target_items = ["FOO", "BAR", "FOO"] with self.assertRaises(ValidationError): ParameterUtil.validate_array_unique(target_items, 'tags')