本文整理汇总了Python中b2handle.handleclient.EUDATHandleClient.generate_PID_name方法的典型用法代码示例。如果您正苦于以下问题:Python EUDATHandleClient.generate_PID_name方法的具体用法?Python EUDATHandleClient.generate_PID_name怎么用?Python EUDATHandleClient.generate_PID_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b2handle.handleclient.EUDATHandleClient
的用法示例。
在下文中一共展示了EUDATHandleClient.generate_PID_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EUDATHandleClientNoaccessTestCase
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import generate_PID_name [as 别名]
class EUDATHandleClientNoaccessTestCase(unittest.TestCase):
def setUp(self):
self.inst = EUDATHandleClient()
def tearDown(self):
pass
# Init
def test_constructor_no_args(self):
"""Test constructor without args: No exception raised."""
inst = EUDATHandleClient()
self.assertIsInstance(inst, EUDATHandleClient,
'Not a client instance!')
def test_constructor_with_url(self):
"""Test constructor with one arg (well-formatted server URL): No exception raised."""
inst = EUDATHandleClient('http://foo.bar')
self.assertIsInstance(inst, EUDATHandleClient,
'Not a client instance!')
def test_constructor_with_url(self):
"""Test constructor with one arg (ill-formatted server URL): No exception raised."""
inst = EUDATHandleClient('foo')
self.assertIsInstance(inst, EUDATHandleClient,
'Not a client instance!')
def test_instantiate_for_read_access(self):
"""Testing if instantiating with default handle server works. """
# Create client instance with username and password
inst = EUDATHandleClient.instantiate_for_read_access()
self.assertIsInstance(inst, EUDATHandleClient)
def test_instantiate_for_read_an_search(self):
"""Testing if instantiating with default handle server works. """
# Try to create client instance for search without a search URL:
with self.assertRaises(TypeError):
inst = EUDATHandleClient.instantiate_for_read_and_search(
None, 'johndoe', 'passywordy')
def test_instantiate_with_username_and_password_noindex(self):
# Try to ceate client instance with username and password
with self.assertRaises(HandleSyntaxError):
inst = EUDATHandleClient.instantiate_with_username_and_password(
'someurl', 'johndoe', 'passywordy')
# PID generation
def test_generate_PID_name_without_prefix(self):
"""Test PID generation without prefix."""
uuid = self.inst.generate_PID_name()
self.assertFalse('/' in uuid,
'There is a slash in the generated PID, even though no prefix was specified.')
def test_generate_PID_name_with_prefix(self):
"""Test PID generation with prefix."""
prefix = 'aprefix'
uuid = self.inst.generate_PID_name(prefix)
self.assertTrue(prefix+'/' in uuid,
'The specified prefix is not present in the generated PID.')
# Handle syntax
def test_check_handle_syntax_normal(self):
"""Test check handle syntax"""
syntax_checked = check_handle_syntax("foo/bar")
self.assertTrue(syntax_checked)
def test_check_handle_syntax_two_slashes(self):
"""Handle Syntax: No exception if too many slashes in handle."""
check_handle_syntax("foo/bar/foo")
def test_check_handle_syntax_no_slashes(self):
"""Handle Syntax: Exception if too many slashes in handle."""
with self.assertRaises(HandleSyntaxError):
check_handle_syntax("foobar")
def test_check_handle_syntax_no_prefix(self):
"""Handle Syntax: Exception if no prefix."""
with self.assertRaises(HandleSyntaxError):
check_handle_syntax("/bar")
def test_check_handle_syntax_no_suffix(self):
"""Handle Syntax: Exception if no suffix."""
with self.assertRaises(HandleSyntaxError):
check_handle_syntax("foo/")
def test_check_handle_syntax_with_index(self):
"""Test check handle syntax with index."""
syntax_checked = check_handle_syntax("300:foo/bar")
self.assertTrue(syntax_checked,
'The syntax of the handle is not index:prefix/suffix.')
def test_check_handle_syntax_none(self):
#.........这里部分代码省略.........