本文整理汇总了Python中b2handle.handleclient.EUDATHandleClient.instantiate_with_username_and_password方法的典型用法代码示例。如果您正苦于以下问题:Python EUDATHandleClient.instantiate_with_username_and_password方法的具体用法?Python EUDATHandleClient.instantiate_with_username_and_password怎么用?Python EUDATHandleClient.instantiate_with_username_and_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b2handle.handleclient.EUDATHandleClient
的用法示例。
在下文中一共展示了EUDATHandleClient.instantiate_with_username_and_password方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_instantiate_with_username_and_password_noindex
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_username_and_password [as 别名]
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')
示例2: test_instantiate_with_username_and_wrong_password
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_username_and_password [as 别名]
def test_instantiate_with_username_and_wrong_password(self):
"""Test instantiation of client: No exception if password wrong."""
# Create client instance with username and password
inst = EUDATHandleClient.instantiate_with_username_and_password(
self.url, self.user, self.randompassword, HTTPS_verify=self.https_verify
)
self.assertIsInstance(inst, EUDATHandleClient)
示例3: setUp
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_username_and_password [as 别名]
def setUp(self):
REQUESTLOGGER.info("\n"+60*"*"+"\nsetUp of EUDATHandleClientWriteaccessTestCase")
self.inst = EUDATHandleClient.instantiate_with_username_and_password(
self.url,
self.user,
self.password,
HTTPS_verify=self.https_verify)
authstring = b2handle.utilhandle.create_authentication_string(self.user, self.password)
self.headers = {
'Content-Type': 'application/json',
'Authorization': 'Basic '+authstring
}
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": "TEST3",
"data":{
"format":"string",
"value":"val3"
}
},
{
"index":4,
"type": "TEST4",
"data":{
"format":"string",
"value":"val4"
}
},
]
testhandle = self.handle
url = self.connector.make_handle_URL(testhandle)
veri = self.https_verify
head = self.headers
data = json.dumps({'values':list_of_all_entries})
resp = requests.put(url, data=data, headers=head, verify=veri)
log_request_response_to_file('PUT', self.handle, url, head, veri, resp)
示例4: test_instantiate_with_username_and_password_inexistentuser
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_username_and_password [as 别名]
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')
示例5: test_instantiate_with_username_and_password_wrongpw
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_username_and_password [as 别名]
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)
示例6: test_instantiate_with_nonexistent_username_and_password
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_username_and_password [as 别名]
def test_instantiate_with_nonexistent_username_and_password(self):
"""Test instantiation of client: Exception if username does not exist."""
testusername_inexistent = "100:" + self.inexistent_handle
# Run code to be tested + check exception:
with self.assertRaises(HandleNotFoundException):
# Create client instance with username and password
inst = EUDATHandleClient.instantiate_with_username_and_password(
self.url, testusername_inexistent, self.randompassword, HTTPS_verify=self.https_verify
)
示例7: test_instantiate_with_username_without_index_and_password
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_username_and_password [as 别名]
def test_instantiate_with_username_without_index_and_password(self):
"""Test instantiation of client: Exception if username has no index."""
testusername_without_index = self.user.split(":")[1]
# Run code to be tested + check exception:
with self.assertRaises(HandleSyntaxError):
# Create client instance with username and password
inst = EUDATHandleClient.instantiate_with_username_and_password(
self.url, testusername_without_index, self.randompassword, HTTPS_verify=self.https_verify
)
示例8: setUp
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_username_and_password [as 别名]
def setUp(self):
REQUESTLOGGER.info("\n"+60*"*"+"\nsetUp of EUDATHandleClientWriteaccess10320LOCTestCase")
self.inst = EUDATHandleClient.instantiate_with_username_and_password(
self.url,
self.user,
self.password,
HTTPS_verify=self.https_verify)
list_of_all_entries_with = [
{
"index":1,
"type":"URL",
"data":"www.url.foo"
},
{
"index":2,
"type":"10320/LOC",
"data":{
"format":"string",
"value":"<locations><location href = 'http://first.foo' /><location href = 'http://second.foo' /></locations> "
}
}
]
list_of_all_entries_without = [
{
"index":1,
"type":"URL",
"data":"www.url.foo"
}
]
authstring = b2handle.utilhandle.create_authentication_string(self.user, self.password)
head = {
'Content-Type': 'application/json',
'Authorization': 'Basic '+authstring
}
veri = self.https_verify
testhandle = self.handle_withloc
url = self.connector.make_handle_URL(testhandle)
data = json.dumps({'values':list_of_all_entries_with})
resp = requests.put(url, data=data, headers=head, verify=veri)
log_request_response_to_file('PUT', testhandle, url, head, veri, resp)
testhandle = self.handle_withoutloc
url = self.connector.make_handle_URL(testhandle)
data = json.dumps({'values':list_of_all_entries_without})
requests.put(url, data=data, headers=head, verify=veri)
log_request_response_to_file('PUT', testhandle, url, head, veri, resp)
示例9: create_required_test_handles
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_username_and_password [as 别名]
def create_required_test_handles(self):
# Creating an instance that knows how to write:
pw = self.testvalues['password']
inst = EUDATHandleClient.instantiate_with_username_and_password(
self.testvalues['handle_server_url_write'],
self.user,
pw,
HTTPS_verify=self.https_verify)
authstring = self.inst.create_authentication_string(self.user, pw)
headers = {
'Content-Type': 'application/json',
'Authorization': 'Basic '+authstring
}
list_of_all_entries = [
{
"index":111,
"type":"test1",
"data":"val1"
},
{
"index":2222,
"type":"test2",
"data":"val2"
},
{
"index":333,
"type":"test3",
"data":"val3"
},
{
"index":4,
"type":"test4",
"data":"val4"
}
]
testhandle = self.handle
url = inst.make_handle_URL(testhandle)
veri = self.https_verify
head = headers
data = json.dumps({'values':list_of_all_entries})
resp = requests.put(url, data=data, headers=head, verify=veri)