def test_5_tag_schema_allows_capital_letters(self): """Asserts that tag names can have capital letters""" ignored = "" data = {"name": u"CAPITALS", "revision_timestamp": ignored, "state": ignored} _, errors = validate(data, default_tags_schema(), self.context) assert not errors, str(errors)
def test_3_tag_schema_allows_spaces(self): """Asserts that a tag name with space is valid""" ignored = "" data = {"name": u"with space", "revision_timestamp": ignored, "state": ignored} _, errors = validate(data, default_tags_schema(), self.context) assert not errors, str(errors)
def showcase_base_schema(): schema = { 'id': [empty], 'revision_id': [ignore], 'name': [not_empty, unicode, name_validator, package_name_validator], 'title': [if_empty_same_as("name"), unicode], 'author': [ignore_missing, unicode], 'author_email': [ignore_missing, unicode], 'notes': [ignore_missing, unicode], 'url': [ignore_missing, unicode], 'state': [ignore_not_package_admin, ignore_missing], 'type': [ignore_missing, unicode], 'log_message': [ignore_missing, unicode, no_http], '__extras': [ignore], '__junk': [empty], 'resources': default_resource_schema(), 'tags': default_tags_schema(), 'tag_string': [ignore_missing, tag_string_convert], 'extras': default_extras_schema(), 'save': [ignore], 'return_to': [ignore], 'image_url': [toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras')], 'original_related_item_id': [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras')] } return schema
def test_4_tag_schema_allows_limited_punctuation(self): """Asserts that a tag name with limited punctuation is valid""" ignored = "" data = {"name": u".-_", "revision_timestamp": ignored, "state": ignored} _, errors = validate(data, default_tags_schema(), self.context) assert not errors, str(errors)
def test_4_tag_schema_allows_limited_punctuation(self): """Asserts that a tag name with limited punctuation is valid""" ignored = "" data = { "name": u".-_", "revision_timestamp": ignored, "state": ignored, } _, errors = validate(data, default_tags_schema(), self.context) assert not errors, str(errors)
def test_3_tag_schema_allows_spaces(self): """Asserts that a tag name with space is valid""" ignored = "" data = { "name": u"with space", "revision_timestamp": ignored, "state": ignored, } _, errors = validate(data, default_tags_schema(), self.context) assert not errors, str(errors)
def test_5_tag_schema_allows_capital_letters(self): """Asserts that tag names can have capital letters""" ignored = "" data = { 'name': u'CAPITALS', 'revision_timestamp': ignored, 'state': ignored } _, errors = validate(data, default_tags_schema(), self.context) assert not errors, str(errors)
def test_4_tag_schema_allows_limited_punctuation(self): """Asserts that a tag name with limited punctuation is valid""" ignored = "" data = { 'name': u'.-_', 'revision_timestamp': ignored, 'state': ignored } _, errors = validate(data, default_tags_schema(), self.context) assert not errors, str(errors)
def test_3_tag_schema_allows_spaces(self): """Asserts that a tag name with space is valid""" ignored = "" data = { 'name': u'with space', 'revision_timestamp': ignored, 'state': ignored } _, errors = validate(data, default_tags_schema(), self.context) assert not errors, str(errors)
def test_5_tag_schema_allows_capital_letters(self): """Asserts that tag names can have capital letters""" ignored = "" data = { "name": u"CAPITALS", "revision_timestamp": ignored, "state": ignored, } _, errors = validate(data, default_tags_schema(), self.context) assert not errors, str(errors)
def validate_tag(tag): patch_translator() logger.info('VALIDATE - %s', tag) tag_json = { 'name': tag } _, errors = validate(tag_json, default_tags_schema()) return errors
def dgua_tags_schema(): schema = default_tags_schema() schema.update({ 'name': [ toolkit.get_validator('not_missing'), toolkit.get_validator('not_empty'), unicode, toolkit.get_validator('tag_length_validator'), dgua_tag_name_validator ] }) return schema
def test_7_tag_schema_disallows_whitespace_other_than_spaces(self): """Asserts whitespace characters, such as tabs, are not allowed.""" not_allowed = "\t\n\r\f\v" ignored = "" data = {"revision_timestamp": ignored, "state": ignored} for ch in not_allowed: data["name"] = "Bad " + ch + " character" _, errors = validate(data, default_tags_schema(), self.context) assert errors, repr(ch) assert "name" in errors error_message = errors["name"][0] assert data["name"] in error_message, error_message assert "must be alphanumeric" in error_message
def test_6_tag_schema_disallows_most_punctuation(self): """Asserts most punctuation is disallowed""" not_allowed = r'!?"\'+=:;@#~[]{}()*&^%$,' ignored = "" data = {"revision_timestamp": ignored, "state": ignored} for ch in not_allowed: data["name"] = "Character " + ch _, errors = validate(data, default_tags_schema(), self.context) assert errors, pprint(errors) assert "name" in errors error_message = errors["name"][0] assert data["name"] in error_message, error_message assert "must be alphanumeric" in error_message
def test_7_tag_schema_disallows_whitespace_other_than_spaces(self): """Asserts whitespace characters, such as tabs, are not allowed.""" not_allowed = "\t\n\r\f\v" ignored = "" data = {"revision_timestamp": ignored, "state": ignored} for ch in not_allowed: data["name"] = "Bad " + ch + " character" _, errors = validate(data, default_tags_schema(), self.context) assert errors, repr(ch) assert "name" in errors error_message = errors["name"][0] assert data["name"] in error_message, error_message assert "can only contain alphanumeric characters" in error_message
def test_7_tag_schema_disallows_whitespace_other_than_spaces(self): """Asserts whitespace characters, such as tabs, are not allowed.""" not_allowed = '\t\n\r\f\v' ignored = "" data = {'revision_timestamp': ignored, 'state': ignored} for ch in not_allowed: data['name'] = "Bad " + ch + " character" _, errors = validate(data, default_tags_schema(), self.context) assert errors, repr(ch) assert 'name' in errors error_message = errors['name'][0] assert data['name'] in error_message, error_message assert "must be alphanumeric" in error_message
def test_6_tag_schema_disallows_most_punctuation(self): """Asserts most punctuation is disallowed""" not_allowed = r'!?"\'+=:;@#~[]{}()*&^%$,' ignored = "" data = {"revision_timestamp": ignored, "state": ignored} for ch in not_allowed: data["name"] = "Character " + ch _, errors = validate(data, default_tags_schema(), self.context) assert errors assert "name" in errors error_message = errors["name"][0] assert data["name"] in error_message, error_message assert "can only contain alphanumeric characters" in error_message
def test_6_tag_schema_disallows_most_punctuation(self): """Asserts most punctuation is disallowed""" not_allowed = r'!?"\'+=:;@#~[]{}()*&^%$,' ignored = "" data = {'revision_timestamp': ignored, 'state': ignored} for ch in not_allowed: data['name'] = "Character " + ch _, errors = validate(data, default_tags_schema(), self.context) assert errors, pprint(errors) assert 'name' in errors error_message = errors['name'][0] assert data['name'] in error_message, error_message assert "must be alphanumeric" in error_message
def showcase_base_schema(): schema = { 'id': [empty], 'revision_id': [ignore], 'name': [not_empty, unicode, name_validator, package_name_validator], 'title': [if_empty_same_as("name"), unicode], 'author': [ignore_missing, unicode], 'author_email': [ignore_missing, unicode], 'notes': [ignore_missing, unicode], 'url': [ignore_missing, unicode], 'state': [ignore_not_package_admin, ignore_missing], 'type': [ignore_missing, unicode], 'log_message': [ignore_missing, unicode, no_http], '__extras': [ignore], '__junk': [empty], 'resources': default_resource_schema(), 'tags': default_tags_schema(), 'tag_string': [ignore_missing, tag_string_convert], 'extras': default_extras_schema(), 'save': [ignore], 'return_to': [ignore], 'groups': [ignore_missing, convert_group_names_to_group_objects], } # Extras schema['image_url'] = [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras') ] schema['original_related_item_id'] = [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras') ] schema['related_datasets'] = [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras') ] schema['related_stories'] = [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras') ] schema['story_date'] = [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras') ] schema['story_type'] = [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras') ] schema['methodology'] = [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras') ] schema['spatial_text'] = [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras') ] schema['author_title'] = [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras') ] schema['author_workplace'] = [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras') ] schema['author_profile'] = [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras') ] # Extras (conditional) if config.get('disqus.name'): schema['allow_commenting'] = [ toolkit.get_validator('ignore_missing'), toolkit.get_validator('boolean_validator'), toolkit.get_converter('convert_to_extras') ] return schema
def tag_create_schema(): schema = default_tags_schema() # You're not allowed to specify your own ID when creating a tag. schema['id'] = [empty] return schema