本文整理汇总了Python中b2handle.handleclient.EUDATHandleClient.is_URL_contained_in_10320LOC方法的典型用法代码示例。如果您正苦于以下问题:Python EUDATHandleClient.is_URL_contained_in_10320LOC方法的具体用法?Python EUDATHandleClient.is_URL_contained_in_10320LOC怎么用?Python EUDATHandleClient.is_URL_contained_in_10320LOC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b2handle.handleclient.EUDATHandleClient
的用法示例。
在下文中一共展示了EUDATHandleClient.is_URL_contained_in_10320LOC方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EUDATHandleClientReadaccessPatchedTestCase
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import is_URL_contained_in_10320LOC [as 别名]
#.........这里部分代码省略.........
with self.assertRaises(HandleNotFoundException):
self.inst.get_value_from_handle(testhandle, key=key)
@mock.patch('b2handle.handleclient.requests.Session.get')
def test_is_10320LOC_empty_handle_does_not_exist(self, getpatch):
"""Test exception"""
# Test variables
testhandle = 'who/cares'
# Define the replacement for the patched method:
mock_response = MockResponse(notfound=True)
getpatch.return_value = mock_response
# Call method and check result:
with self.assertRaises(HandleNotFoundException):
self.inst.is_10320LOC_empty(testhandle)
@mock.patch('b2handle.handleclient.requests.Session.get')
def test_is_url_contained_in_10320LOC_handle_does_not_exist(self, getpatch):
"""Test exception"""
# Test variables
testhandle = 'who/cares'
one_url = 'http://bla'
list_of_urls = ['http://bla','http://foo.foo']
# Define the replacement for the patched method:
mock_response = MockResponse(notfound=True)
getpatch.return_value = mock_response
# Call method and check result:
with self.assertRaises(HandleNotFoundException):
self.inst.is_URL_contained_in_10320LOC(testhandle, url=one_url)
with self.assertRaises(HandleNotFoundException):
self.inst.is_URL_contained_in_10320LOC(testhandle, url=list_of_urls)
# Instantiation
@mock.patch('b2handle.handleclient.requests.Session.get')
def test_instantiate_with_username_and_password_wrongpw(self, getpatch):
# Define the replacement for the patched method:
mock_response = MockResponse(success=True)
getpatch.return_value = mock_response
inst = EUDATHandleClient.instantiate_with_username_and_password(
'http://someurl', '100:my/testhandle', 'passywordy')
self.assertIsInstance(inst, EUDATHandleClient)
@mock.patch('b2handle.handleclient.requests.Session.get')
def test_instantiate_with_username_and_password_inexistentuser(self, getpatch):
# Define the replacement for the patched method:
mock_response = MockResponse(notfound=True)
getpatch.return_value = mock_response
with self.assertRaises(HandleNotFoundException):
inst = EUDATHandleClient.instantiate_with_username_and_password(
'http://someurl', '100:john/doe', 'passywordy')
@mock.patch('b2handle.handleclient.requests.Session.get')
def test_instantiate_with_credentials_inexistentuser(self, getpatch):
"""Test instantiation of client: Exception if username does not exist."""
示例2: EUDATHandleClientReadaccessPatchedTestCase
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import is_URL_contained_in_10320LOC [as 别名]
#.........这里部分代码省略.........
with self.assertRaises(HandleNotFoundException):
self.inst.check_if_username_exists(testhandle)
@patch("b2handle.handleclient.requests.get")
def test_is_10320LOC_empty_handle_does_not_exist(self, getpatch):
"""Test exception"""
# Test variables
testhandle = "who/cares"
# Define the replacement for the patched method:
mock_response = MockResponse(notfound=True)
getpatch.return_value = mock_response
# Call method and check result:
with self.assertRaises(HandleNotFoundException):
self.inst.is_10320LOC_empty(testhandle)
@patch("b2handle.handleclient.requests.get")
def test_is_url_contained_in_10320LOC_handle_does_not_exist(self, getpatch):
"""Test exception"""
# Test variables
testhandle = "who/cares"
one_url = "http://bla"
list_of_urls = ["http://bla", "http://foo.foo"]
# Define the replacement for the patched method:
mock_response = MockResponse(notfound=True)
getpatch.return_value = mock_response
# Call method and check result:
with self.assertRaises(HandleNotFoundException):
self.inst.is_URL_contained_in_10320LOC(testhandle, url=one_url)
with self.assertRaises(HandleNotFoundException):
self.inst.is_URL_contained_in_10320LOC(testhandle, url=list_of_urls)
# Instantiation
@patch("b2handle.handleclient.requests.get")
def test_instantiate_with_username_and_password_wrongpw(self, getpatch):
# Define the replacement for the patched method:
mock_response = MockResponse(success=True)
getpatch.return_value = mock_response
inst = EUDATHandleClient.instantiate_with_username_and_password(
"http://someurl", "100:my/testhandle", "passywordy"
)
self.assertIsInstance(inst, EUDATHandleClient)
@patch("b2handle.handleclient.requests.get")
def test_instantiate_with_username_and_password_inexistentuser(self, getpatch):
# Define the replacement for the patched method:
mock_response = MockResponse(notfound=True)
getpatch.return_value = mock_response
with self.assertRaises(HandleNotFoundException):
inst = EUDATHandleClient.instantiate_with_username_and_password(
"http://someurl", "100:john/doe", "passywordy"
)
@patch("b2handle.handleclient.requests.get")
def test_instantiate_with_credentials_inexistentuser(self, getpatch):
示例3: EUDATHandleClientReadaccessFakedTestCase
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import is_URL_contained_in_10320LOC [as 别名]
#.........这里部分代码省略.........
self.assertEqual(indices[0], 3,
'The index of "test1" is not 3.')
def test_get_indices_for_key_duplicatekey(self):
"""Test getting the indices for a duplicate key."""
handlerecord = json.load(open('resources/handlerecord_for_reading.json'))
handle = handlerecord['handle']
indices = self.inst.get_handlerecord_indices_for_key('testdup', handlerecord['values'])
self.assertEqual(len(indices),2,
'There is more or less than 2 indices!')
self.assertIn(5, indices,
'5 is not in indices for key "testdup".')
self.assertIn(6, indices,
'6 is not in indices for key "testdup".')
def test_get_indices_for_key_inexistentkey(self):
"""Test getting the indices for an inexistent key."""
handlerecord = json.load(open('resources/handlerecord_for_reading.json'))
handle = handlerecord['handle']
indices = self.inst.get_handlerecord_indices_for_key('test100', handlerecord['values'])
self.assertEqual(len(indices),0,
'There is more than 0 index!')
self.assertEqual(indices,[],
'Indices should be an empty list!')
# is_10320LOC_empty
def test_is_10320LOC_empty_notempty(self):
"""Test if presence of 10320/LOC is detected."""
handlerecord = json.load(open('resources/handlerecord_with_10320LOC.json'))
handle = handlerecord['handle']
answer = self.inst.is_10320LOC_empty(handle, handlerecord)
self.assertFalse(answer,
'The record contains a 10320/LOC, but the is_empty does not return False.')
def test_is_10320LOC_empty_no10320LOC(self):
"""Test if absence of 10320/LOC is detected."""
handlerecord = json.load(open('resources/handlerecord_without_10320LOC.json'))
handle = handlerecord['handle']
answer = self.inst.is_10320LOC_empty(handle, handlerecord)
self.assertTrue(answer,
'The record contains no 10320/LOC, but the is_empty does not return True.')
def test_is_10320LOC_empty_empty10320LOC(self):
"""Test if emptiness of 10320/LOC is detected."""
handlerecord = json.load(open('resources/handlerecord_with_empty_10320LOC.json'))
handle = handlerecord['handle']
answer = self.inst.is_10320LOC_empty(handle, handlerecord)
self.assertTrue(answer,
'The record contains an empty 10320/LOC, but the is_empty does not return True.')
# is_URL_contained_in_1302loc
def test_is_URL_contained_in_10320LOC_true(self):
"""Test if presence of URL is found in 10320/LOC."""
handlerecord = json.load(open('resources/handlerecord_with_10320LOC.json'))
handle = handlerecord['handle']
answer = self.inst.is_URL_contained_in_10320LOC(handle,
'http://foo.bar',
handlerecord)
val = self.inst.get_value_from_handle(handle, '10320/LOC', handlerecord)
self.assertTrue(answer,
'The URL exists in the 10320/LOC, and still the method does not return True:\n'+str(val))
def test_is_URL_contained_in_10320LOC_false(self):
"""Test if absence of URL is detected in existing 10320/LOC."""
handlerecord = json.load(open('resources/handlerecord_with_10320LOC.json'))
handle = handlerecord['handle']
answer = self.inst.is_URL_contained_in_10320LOC(handle,
'http://bar.bar',
handlerecord)
self.assertFalse(answer,
'The 10320/LOC does not contain the URL, and still the method does not return False.')
def test_is_URL_contained_in_inexistent_10320LOC(self):
"""Test if absence of URL is detected if 10320/LOC does not exist."""
handlerecord = json.load(open('resources/handlerecord_without_10320LOC.json'))
handle = handlerecord['handle']
answer = self.inst.is_URL_contained_in_10320LOC(handle,
'http://whatever.foo',
handlerecord)
self.assertFalse(answer,
'The 10320/LOC does not exist, and still the method does not return False.')
def test_is_URL_contained_in_empty_10320LOC(self):
"""Test if absence of URL is detected if 10320/LOC is empty."""
handlerecord = json.load(open('resources/handlerecord_with_empty_10320LOC.json'))
handle = handlerecord['handle']
answer = self.inst.is_URL_contained_in_10320LOC(handle,
'http://whatever.foo',
handlerecord)
self.assertFalse(answer,
'The 10320/LOC is empty, and still the method does not return False.')
示例4: EUDATHandleClientReadaccessFaked10320LOCTestCase
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import is_URL_contained_in_10320LOC [as 别名]
class EUDATHandleClientReadaccessFaked10320LOCTestCase(unittest.TestCase):
'''Testing methods that read the 10320/LOC entry.'''
def setUp(self):
self.inst = EUDATHandleClient()
def tearDown(self):
pass
# is_10320LOC_empty
def test_is_10320LOC_empty_notempty(self):
"""Test if presence of 10320/LOC is detected."""
handlerecord = RECORD_WITH
handle = handlerecord['handle']
answer = self.inst.is_10320LOC_empty(handle, handlerecord)
self.assertFalse(answer,
'The record contains a 10320/LOC, but the is_empty does not return False.')
def test_is_10320LOC_empty_no10320LOC(self):
"""Test if absence of 10320/LOC is detected."""
handlerecord = RECORD_WITHOUT
handle = handlerecord['handle']
answer = self.inst.is_10320LOC_empty(handle, handlerecord)
self.assertTrue(answer,
'The record contains no 10320/LOC, but the is_empty does not return True.')
def test_is_10320LOC_empty_empty10320LOC(self):
"""Test if emptiness of 10320/LOC is detected."""
handlerecord = RECORD_WITH_EMPTY
handle = handlerecord['handle']
answer = self.inst.is_10320LOC_empty(handle, handlerecord)
self.assertTrue(answer,
'The record contains an empty 10320/LOC, but the is_empty does not return True.')
# is_URL_contained_in_1302loc
def test_is_URL_contained_in_10320LOC_true(self):
"""Test if presence of URL is found in 10320/LOC."""
handlerecord = RECORD_WITH
handle = handlerecord['handle']
answer = self.inst.is_URL_contained_in_10320LOC(handle,
'http://foo.bar',
handlerecord)
val = self.inst.get_value_from_handle(handle, '10320/LOC', handlerecord)
self.assertTrue(answer,
'The URL exists in the 10320/LOC, and still the method does not return True:\n'+str(val))
def test_is_URL_contained_in_10320LOC_false(self):
"""Test if absence of URL is detected in existing 10320/LOC."""
handlerecord = RECORD_WITH
handle = handlerecord['handle']
answer = self.inst.is_URL_contained_in_10320LOC(handle,
'http://bar.bar',
handlerecord)
self.assertFalse(answer,
'The 10320/LOC does not contain the URL, and still the method does not return False.')
def test_is_URL_contained_in_inexistent_10320LOC(self):
"""Test if absence of URL is detected if 10320/LOC does not exist."""
handlerecord = RECORD_WITHOUT
handle = handlerecord['handle']
answer = self.inst.is_URL_contained_in_10320LOC(handle,
'http://whatever.foo',
handlerecord)
self.assertFalse(answer,
'The 10320/LOC does not exist, and still the method does not return False.')
def test_is_URL_contained_in_empty_10320LOC(self):
"""Test if absence of URL is detected if 10320/LOC is empty."""
handlerecord = RECORD_WITH_EMPTY
handle = handlerecord['handle']
answer = self.inst.is_URL_contained_in_10320LOC(handle,
'http://whatever.foo',
handlerecord)
self.assertFalse(answer,
'The 10320/LOC is empty, and still the method does not return False.')