本文整理汇总了Python中utilities.log_new_test_case函数的典型用法代码示例。如果您正苦于以下问题:Python log_new_test_case函数的具体用法?Python log_new_test_case怎么用?Python log_new_test_case使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_new_test_case函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_exchange_additional_URL_normal
def test_exchange_additional_URL_normal(self):
"""Test replacing an URL."""
log_new_test_case("test_exchange_additional_URL_normal")
# Test variables
testhandle = self.handle_withloc
old = 'http://first.foo'
new = 'http://newfirst.foo'
# Precondition: URL must be included.
handlerecord_json = self.inst.retrieve_handle_record_json(testhandle)
contained = self.inst.is_URL_contained_in_10320LOC(testhandle, old, handlerecord_json)
self.assertTrue(contained,
'Precondition for test failed! The URL should be present at the start'
' of the test: '+str(handlerecord_json))
# Run the code to be tested:
log_start_test_code()
self.inst.exchange_additional_URL(testhandle, old, new)
log_end_test_code()
# Check desired effects on handle:
contained = self.inst.is_URL_contained_in_10320LOC(testhandle, new)
self.assertTrue(contained,
'After replacing an URL, the replacement was not there.')
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:25,代码来源:handleclient_writeaccess_10320_test.py
示例2: test_remove_additional_URL_several
def test_remove_additional_URL_several(self):
"""Test removing all URL at the same time, which should remove the whole 10320/LOC attribute."""
log_new_test_case("test_remove_additional_URL_several")
# Test variables
testhandle = self.handle_withloc
url1 = 'http://first.foo'
url2 = 'http://second.foo'
# Run code to be tested:
log_start_test_code()
self.inst.remove_additional_URL(testhandle, url1, url2)
log_end_test_code()
# Check desired effects on handle:
# Check if empty:
isempty = self.inst.is_10320LOC_empty(testhandle)
self.assertTrue(isempty,
'After removing all URLs from 10320/LOC, it is not empty.')
# Check if still exists:
rec = self.inst.retrieve_handle_record_json(testhandle)
val = self.inst.get_value_from_handle(testhandle, '10320/LOC', rec)
indices = self.inst.get_handlerecord_indices_for_key('10320/LOC', rec['values'])
self.assertIsNone(val,
'After removing all URLs from 10320/LOC, the value is not None.')
self.assertEqual(len(indices), 0,
'After removing all URLs from 10320/LOC, the entry still exists.')
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:27,代码来源:handleclient_writeaccess_10320_test.py
示例3: test_modify_handle_value_several
def test_modify_handle_value_several(self):
"""Test modifying several existing handle values."""
log_new_test_case("test_modify_handle_value_several")
# Test variables
testhandle = self.handle
# Run code to be tested:
log_start_test_code()
self.inst.modify_handle_value(testhandle,
test4='new4',
test2='new2',
test3='new3')
log_end_test_code()
# Check desired effects on handle:
# check if three values were modified:
rec = self.inst.retrieve_handle_record_json(testhandle)
val2 = self.inst.get_value_from_handle(testhandle, 'test2', rec)
val3 = self.inst.get_value_from_handle(testhandle, 'test3', rec)
val4 = self.inst.get_value_from_handle(testhandle, 'test4', rec)
self.assertEqual(val2, 'new2',
'The value of "test2" was not changed to "new2".')
self.assertEqual(val3, 'new3',
'The value of "test3" was not changed to "new3".')
self.assertEqual(val4, 'new4',
'The value of "test4" was not changed to "new4".')
# check if one value remained unchanged:
val1 = self.inst.get_value_from_handle(testhandle, 'test1', rec)
self.assertEqual(val1, 'val1',
'The value of "test1" should still be "val1".')
开发者ID:TonyWildish,项目名称:B2HANDLE,代码行数:32,代码来源:handleclient_writeaccess_test.py
示例4: test_search_handle_prefixfilter
def test_search_handle_prefixfilter(self):
"""Test filtering for prefixes."""
log_new_test_case("test_search_handle_prefixfilter")
prefix1 = self.prefix_inexistent
prefix2 = self.handle.split('/')[0]
log_start_test_code()
val1 = self.inst.search_handle(URL='*dkrz*', prefix=prefix1)
log_end_test_code()
log_start_test_code()
val2 = self.inst.search_handle(URL='*dkrz*', prefix=prefix2)
log_end_test_code()
# Check desired outcome:
self.assertEqual(type(val1),type([]),
'Searching did not return a list, but: '+str(val1)+', type: '+str(type(val1)))
for item in val1:
self.assertEqual(item.split('/')[0], prefix1,
'This search result has the wrong prefix: '+item+', should be '+prefix1)
self.assertEqual(type(val2),type([]),
'Searching did not return a list, but: '+str(val1)+', type: '+str(type(val1)))
for item in val2:
self.assertEqual(item.split('/')[0], prefix2,
'This search result has the wrong prefix: '+item+', should be '+prefix2)
开发者ID:TonyWildish,项目名称:B2HANDLE,代码行数:26,代码来源:handleclient_searchaccess_test.py
示例5: test_modify_handle_value_one
def test_modify_handle_value_one(self):
"""Test modifying one existing handle value."""
log_new_test_case("test_modify_handle_value_one")
# Test variables
testhandle = self.handle
# Run code to be tested:
log_start_test_code()
self.inst.modify_handle_value(testhandle, TEST4='newvalue')
log_end_test_code()
# Check desired effects on handle:
# check if one was modified:
rec = self.inst.retrieve_handle_record_json(testhandle)
val = self.inst.get_value_from_handle(testhandle, 'TEST4', rec)
self.assertEqual(val, 'newvalue',
'The value did not change.')
# check if others still there:
val1 = self.inst.get_value_from_handle(testhandle, 'TEST1', rec)
val2 = self.inst.get_value_from_handle(testhandle, 'TEST2', rec)
self.assertEqual(val1, 'val1',
'The value of "TEST1" should still be "val1".')
self.assertEqual(val2, 'val2',
'The value of "TEST2" should still be "val2".')
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:26,代码来源:handleclient_writeaccess_test.py
示例6: test_delete_handle_value_several_entries
def test_delete_handle_value_several_entries(self):
"""Test deleting several entries from a record."""
log_new_test_case("test_delete_handle_value_several_entries")
# Test variables
testhandle = self.handle
# Run code to be tested:
log_start_test_code()
self.inst.delete_handle_value(testhandle, ['TEST1', 'TEST2'])
log_end_test_code()
# Check desired effects on handle:
rec = self.inst.retrieve_handle_record_json(testhandle)
val1 = self.inst.get_value_from_handle(testhandle, 'TEST1', rec)
val2 = self.inst.get_value_from_handle(testhandle, 'TEST2', rec)
indices1 = self.inst.get_handlerecord_indices_for_key('TEST1', rec['values'])
indices2 = self.inst.get_handlerecord_indices_for_key('TEST2', rec['values'])
self.assertIsNone(val1,
'The value for the deleted entry should be None.')
self.assertIsNone(val2,
'The value for the deleted entry should be None.')
self.assertEqual(len(indices1), 0,
'There should be no index for the deleted entry.')
self.assertEqual(len(indices2), 0,
'There should be no index for the deleted entry.')
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:27,代码来源:handleclient_writeaccess_test.py
示例7: test_add_additional_URL_alreadythere
def test_add_additional_URL_alreadythere(self):
"""Test adding an URL that is already there."""
log_new_test_case("test_add_additional_URL_alreadythere")
# Test variables
testhandle = self.handle_withloc
url = 'http://first.foo'
# Precondition: URL is already contained:
record_before = self.inst.retrieve_handle_record_json(testhandle)
contained = self.inst.is_URL_contained_in_10320LOC(testhandle, url, record_before)
self.assertTrue(contained,
'Test precondition failed: URL not there: '+str(record_before))
# Run code to be tested:
log_start_test_code()
self.inst.add_additional_URL(testhandle, url)
log_end_test_code()
# Check desired effects on handle:
# i.e. check if something has changed
record_after = self.inst.retrieve_handle_record_json(testhandle)
self.assertEqual(record_before, record_after,
'After adding the same URL again, '
'the record was not equal.\n'
'Before:\n'+str(record_before)+'\n'
'After:\n'+str(record_after))
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:27,代码来源:handleclient_writeaccess_10320_test.py
示例8: test_modify_handle_value_several_inexistent
def test_modify_handle_value_several_inexistent(self):
"""Test modifying several existing handle values, one of them inexistent."""
log_new_test_case("test_modify_handle_value_several_inexistent")
# Test variables
testhandle = self.handle
# Run code to be tested:
log_start_test_code()
self.inst.modify_handle_value(testhandle,
TEST4='new4',
TEST2='new2',
TEST100='new100')
log_end_test_code()
# Check desired effects on handle:
# check if three values were modified:
rec = self.inst.retrieve_handle_record_json(testhandle)
val2 = self.inst.get_value_from_handle(testhandle, 'TEST2', rec)
val100 = self.inst.get_value_from_handle(testhandle, 'TEST100', rec)
val4 = self.inst.get_value_from_handle(testhandle, 'TEST4', rec)
self.assertEqual(val100, 'new100',
'The value of "TEST100" was not created and set to "new100".')
self.assertEqual(val2, 'new2',
'The value of "TEST2" was not changed to "new2".')
self.assertEqual(val4, 'new4',
'The value of "TEST4" was not changed to "new4".')
# check if one value remained unchanged:
val1 = self.inst.get_value_from_handle(testhandle, 'TEST1', rec)
self.assertEqual(val1, 'val1',
'The value of "TEST1" should still be "val1".')
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:32,代码来源:handleclient_writeaccess_test.py
示例9: test_add_additional_URL_several
def test_add_additional_URL_several(self):
"""Test adding several (3) additional URLs."""
log_new_test_case("test_add_additional_URL_several")
# Test variables
testhandle = self.handle_withloc
url1 = 'http://one'
url2 = 'http://two'
url3 = 'http://three'
# Run code to be tested:
log_start_test_code()
self.inst.add_additional_URL(testhandle, url1, url2, url3)
log_end_test_code()
# Check desired effects on handle:
contained1 = self.inst.is_URL_contained_in_10320LOC(testhandle, url1)
contained2 = self.inst.is_URL_contained_in_10320LOC(testhandle, url2)
contained3 = self.inst.is_URL_contained_in_10320LOC(testhandle, url3)
self.assertTrue(contained1,
'The first added URL was not added.')
self.assertTrue(contained2,
'The second added URL was not added.')
self.assertTrue(contained3,
'The third added URL was not added.')
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:25,代码来源:handleclient_writeaccess_10320_test.py
示例10: test_register_handle
def test_register_handle(self):
"""Test registering a new handle with various types of values."""
log_new_test_case("test_register_handle")
# Test variables
testhandle = self.newhandle
additional_URLs = ['http://bar.bar', 'http://foo.foo']
# Run code to be tested:
log_start_test_code()
handle_returned = self.inst.register_handle(testhandle,
location='http://foo.bar',
checksum='123456',
additional_URLs=additional_URLs,
FOO='foo',
BAR='bar')
log_end_test_code()
# Check desired effects on handle:
# Check if content was written ok:
rec = self.inst.retrieve_handle_record_json(testhandle)
val1 = self.inst.get_value_from_handle(testhandle, 'BAR', rec)
val2 = self.inst.get_value_from_handle(testhandle, 'FOO', rec)
val3 = self.inst.get_value_from_handle(testhandle, 'URL', rec)
val4 = self.inst.get_value_from_handle(testhandle, 'CHECKSUM', rec)
contained1 = self.inst.is_URL_contained_in_10320LOC(testhandle, 'http://bar.bar', rec)
contained2 = self.inst.is_URL_contained_in_10320LOC(testhandle, 'http://foo.foo', rec)
self.assertEqual(handle_returned, testhandle,
'The handle returned by the create-method was not the one passed to it.')
self.assertEqual(val1, 'bar',
'The value "bar" was not inserted.')
self.assertEqual(val2, 'foo',
'The value "foo" was not inserted.')
self.assertEqual(val3, 'http://foo.bar',
'The value "http://foo.bar" was not inserted.')
self.assertEqual(val4, '123456',
'The value "123456" was not inserted.')
self.assertTrue(contained1,
'A specified additional URL was not inserted.')
self.assertTrue(contained2,
'A specified additional URL was not inserted.')
# Delete again (and check if was deleted):
handle = self.newhandle
url = self.connector.make_handle_URL(self.newhandle)
head = self.headers
veri = self.https_verify
resp = requests.delete(url, headers=head, verify=veri)
log_request_response_to_file('DELETE', handle, url, head, veri, resp)
rec = self.inst.retrieve_handle_record_json(self.newhandle)
self.assertEqual(resp.status_code, 200,
'Deleting did not return a HTTP 200 code.')
self.assertIsNone(rec,
'The deleted record should return None.')
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:56,代码来源:handleclient_writeaccess_test.py
示例11: test_modify_handle_value_corrupted
def test_modify_handle_value_corrupted(self):
"""Test exception when trying to modify corrupted handle record."""
log_new_test_case("test_modify_handle_value_corrupted")
# Test variables
testhandle = self.handle
head = self.headers
url = self.connector.make_handle_URL(testhandle)
# Create corrupted record:
list_of_all_entries = [
{
"index":111,
"type": "TEST1",
"data":{
"format":"string",
"value":"val1"
}
},
{
"index":2222,
"type": "TEST2",
"data":{
"format":"string",
"value":"val2"
}
},
{
"index":333,
"type": "TEST2",
"data":{
"format":"string",
"value":"val3"
}
},
{
"index":4,
"type": "TEST4",
"data":{
"format":"string",
"value":"val4"
}
}
]
data = json.dumps({'values':list_of_all_entries})
veri = self.https_verify
resp = requests.put(url, data=data, headers=head, verify=veri)
log_request_response_to_file('PUT', testhandle, url, head, veri, resp, data)
# Run code to be tested + check exception:
log_start_test_code()
with self.assertRaises(BrokenHandleRecordException):
self.inst.modify_handle_value(testhandle,
TEST4='new4',
TEST2='new2',
TEST3='new3')
log_end_test_code()
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:56,代码来源:handleclient_writeaccess_test.py
示例12: test_search_handle_for_url_and_CHECKSUM
def test_search_handle_for_url_and_CHECKSUM(self):
"""Test searching for url and checksum with wildcards."""
log_new_test_case("test_search_handle_for_url_and_CHECKSUM")
log_start_test_code()
with self.assertRaises(ReverseLookupException):
val1 = self.inst.search_handle('*dkrz*', CHECKSUM='*123*')
log_end_test_code()
log_start_test_code()
val2 = self.inst.search_handle(URL='*dkrz*', CHECKSUM='*123*')
log_end_test_code()
开发者ID:TonyWildish,项目名称:B2HANDLE,代码行数:11,代码来源:handleclient_searchaccess_test.py
示例13: test_generate_and_register_handle
def test_generate_and_register_handle(self):
"""Test generating and registering a new handle with various types of values."""
log_new_test_case("test_generate_and_register_handle")
# Test variables
additional_URLs = ['http://bar.bar', 'http://foo.foo']
prefix = self.prefix
# Run code to be tested:
log_start_test_code()
handle_returned = self.inst.generate_and_register_handle(prefix=prefix,
location='http://foo.bar',
checksum='123456',
additional_URLs=additional_URLs,
foo='foo',
bar='bar')
log_end_test_code()
# Check desired effects on handle:
rec = self.inst.retrieve_handle_record_json(handle_returned)
val1 = self.inst.get_value_from_handle(handle_returned, 'bar', rec)
val2 = self.inst.get_value_from_handle(handle_returned, 'foo', rec)
val3 = self.inst.get_value_from_handle(handle_returned, 'URL', rec)
val4 = self.inst.get_value_from_handle(handle_returned, 'checksum', rec)
contained1 = self.inst.is_URL_contained_in_10320LOC(handle_returned, 'http://bar.bar', rec)
contained2 = self.inst.is_URL_contained_in_10320LOC(handle_returned, 'http://foo.foo', rec)
self.assertEqual(val1, 'bar',
'The value "bar" was not inserted.')
self.assertEqual(val2, 'foo',
'The value "foo" was not inserted.')
self.assertEqual(val3, 'http://foo.bar',
'The value "http://foo.bar" was not inserted.')
self.assertEqual(val4, '123456',
'The value "123456" was not inserted.')
self.assertTrue(contained1,
'A specified additional URL was not inserted.')
self.assertTrue(contained2,
'A specified additional URL was not inserted.')
self.assertIn(prefix, handle_returned,
'The returned handle does not contain the given prefix.')
# Delete again (and check if was deleted):
url = self.inst.make_handle_URL(handle_returned)
head = self.headers
veri = self.https_verify
resp = requests.delete(url, headers=head, verify=veri)
log_request_response_to_file('DELETE', handle_returned, url, head, veri, resp)
rec = self.inst.retrieve_handle_record_json(handle_returned)
self.assertEqual(resp.status_code, 200,
'Deleting did not return a HTTP 200 code.')
self.assertIsNone(rec,
'The deleted record should return None.')
开发者ID:TonyWildish,项目名称:B2HANDLE,代码行数:54,代码来源:handleclient_writeaccess_test.py
示例14: test_modify_handle_value_HS_ADMIN
def test_modify_handle_value_HS_ADMIN(self):
"""Test exception when trying to modify HS_ADMIN."""
log_new_test_case("test_modify_handle_value_HS_ADMIN")
# Test variables
testhandle = self.handle
# Run code to be tested + check exception:
log_start_test_code()
with self.assertRaises(IllegalOperationException):
self.inst.modify_handle_value(testhandle, HS_ADMIN='please let me in!')
log_end_test_code()
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:12,代码来源:handleclient_writeaccess_test.py
示例15: test_delete_handle_too_many_args
def test_delete_handle_too_many_args(self):
"""Test deleting an entire record, but we pass more arguments to the method."""
log_new_test_case("test_delete_handle_too_many_args")
# Test variables
testhandle = self.handle
# Run code to be tested + check exception:
log_start_test_code()
with self.assertRaises(TypeError):
self.inst.delete_handle(testhandle, 'TEST1')
log_end_test_code()
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:12,代码来源:handleclient_writeaccess_test.py
示例16: test_remove_additional_URL_inexistent_handle
def test_remove_additional_URL_inexistent_handle(self):
"""Test normal removal of additional URL from an inexistent handle."""
log_new_test_case("test_remove_additional_URL_inexistent_handle")
# Test variables
testhandle = self.inexistent_handle
url = 'http://first.foo'
# Run code to be tested + check exception:
log_start_test_code()
with self.assertRaises(HandleNotFoundException):
self.inst.remove_additional_URL(testhandle, url)
log_end_test_code()
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:13,代码来源:handleclient_writeaccess_10320_test.py
示例17: test_add_additional_URL_to_inexistent_handle
def test_add_additional_URL_to_inexistent_handle(self):
"""Test exception if handle does not exist."""
log_new_test_case("test_add_additional_URL_to_inexistent_handle")
# Test variables
testhandle = self.inexistent_handle
url = 'http://foo.foo'
# Run code to be tested + check exception:
log_start_test_code()
with self.assertRaises(HandleNotFoundException):
self.inst.add_additional_URL(testhandle, url)
log_end_test_code()
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:13,代码来源:handleclient_writeaccess_10320_test.py
示例18: test_modify_handle_value_without_authentication
def test_modify_handle_value_without_authentication(self):
"""Test if exception when not authenticated."""
log_new_test_case("test_modify_handle_value_without_authentication")
# Test variables
testhandle = self.handle
inst_readonly = EUDATHandleClient(self.url, HTTPS_verify=self.https_verify)
# Run code to be tested + check exception:
log_start_test_code()
with self.assertRaises(HandleAuthenticationError):
inst_readonly.modify_handle_value(testhandle, foo='bar')
log_end_test_code()
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:13,代码来源:handleclient_writeaccess_test.py
示例19: test_search_handle_emptylist
def test_search_handle_emptylist(self):
"""Test empty search result."""
log_new_test_case("test_search_handle_emptylist")
log_start_test_code()
val = self.inst.search_handle(URL=self.url_inexistent)
log_end_test_code()
# Check desired outcome:
self.assertEqual(type(val),type([]),
'Searching did not return a list, but: '+str(val)+', type: '+str(type(val)))
self.assertEqual(len(val),0,
'Searching did not return an empty list, but: '+str(val))
开发者ID:TonyWildish,项目名称:B2HANDLE,代码行数:13,代码来源:handleclient_searchaccess_test.py
示例20: test_search_handle
def test_search_handle(self):
"""Test searching for handles with any url (server should return list of handles)."""
log_new_test_case("test_search_handle")
log_start_test_code()
val = self.inst.search_handle(URL='*')
log_end_test_code()
# Check desired outcome:
self.assertEqual(type(val),type([]),
'Searching did not return a list, but: '+str(val))
self.assertTrue(len(val) > 0,
'Searching did not return any handles!')
self.assertTrue(self.inst.check_handle_syntax(val[0]),
'Searching returned handles with a wrong syntax, e.g.: '+str(val[0]))
开发者ID:TonyWildish,项目名称:B2HANDLE,代码行数:15,代码来源:handleclient_searchaccess_test.py
注:本文中的utilities.log_new_test_case函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论