本文整理汇总了Python中lunr.api.controller.volume.VolumeController._validate_name方法的典型用法代码示例。如果您正苦于以下问题:Python VolumeController._validate_name方法的具体用法?Python VolumeController._validate_name怎么用?Python VolumeController._validate_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lunr.api.controller.volume.VolumeController
的用法示例。
在下文中一共展示了VolumeController._validate_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_validate_name
# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import _validate_name [as 别名]
def test_validate_name(self):
c = Controller({'account_id': self.account_id, 'id': 'test'},
self.mock_app)
req = Request.blank('')
valid_name = c._validate_name(req.params)
# default to id
self.assertEqual(valid_name, 'test')
name = 'aSDf'
req = Request.blank('?name=%s' % name)
valid_name = c._validate_name(req.params)
self.assertEqual(valid_name, name)
# only allow alphanumeric and dashes
name = 'asdf_42'
req = Request.blank('?name=%s' % name)
self.assertRaises(HTTPPreconditionFailed, c._validate_name, req.params)
# only allow alphanumeric and dashes
name = 'asdf*+42'
req = Request.blank('?name=%s' % name)
self.assertRaises(HTTPPreconditionFailed, c._validate_name, req.params)
name = 'asdf 2'
req = Request.blank('?name=%s' % name)
self.assertRaises(HTTPPreconditionFailed, c._validate_name, req.params)