本文整理汇总了Python中swift.common.direct_client.direct_post_object函数的典型用法代码示例。如果您正苦于以下问题:Python direct_post_object函数的具体用法?Python direct_post_object怎么用?Python direct_post_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了direct_post_object函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_direct_post_object
def test_direct_post_object(self):
headers = {'Key': 'value'}
resp_headers = []
with mocked_http_conn(200, resp_headers) as conn:
direct_client.direct_post_object(
self.node, self.part, self.account, self.container, self.obj,
headers)
self.assertEqual(conn.method, 'POST')
self.assertEqual(conn.path, self.obj_path)
for header in headers:
self.assertEqual(conn.req_headers[header], headers[header])
开发者ID:aureliengoulon,项目名称:swift,代码行数:14,代码来源:test_direct_client.py
示例2: test_direct_post_object
def test_direct_post_object(self):
node = {'ip': '1.2.3.4', 'port': '6000', 'device': 'sda'}
part = '0'
account = 'a'
container = 'c'
name = 'o'
headers = {'Key': 'value'}
fake_headers = []
was_http_connector = direct_client.http_connect
direct_client.http_connect = mock_http_connect(200, fake_headers)
direct_client.direct_post_object(node, part, account,
container, name, headers)
self.assertEqual(headers['Key'], fake_headers[0].get('Key'))
direct_client.http_connect = was_http_connector
开发者ID:674009287,项目名称:swift,代码行数:18,代码来源:test_direct_client.py
示例3: run_quarantine_zero_byte_post
def run_quarantine_zero_byte_post(self):
container = 'container-zbyte-%s' % uuid4()
obj = 'object-zbyte-%s' % uuid4()
onode, opart, data_file = self._setup_data_file(container, obj, 'DATA')
metadata = read_metadata(data_file)
unlink(data_file)
with open(data_file, 'w') as fpointer:
write_metadata(fpointer, metadata)
try:
direct_client.direct_post_object(
onode, opart, self.account,
container, obj,
{'X-Object-Meta-1': 'One', 'X-Object-Meta-Two': 'Two'},
conn_timeout=1,
response_timeout=1)
raise Exception("Did not quarantine object")
except client.ClientException as err:
self.assertEquals(err.http_status, 404)
开发者ID:BlueSkyChina,项目名称:swift,代码行数:19,代码来源:test_object_failures.py
示例4: test_direct_post_object_error
def test_direct_post_object_error(self):
headers = {'Key': 'value'}
with mocked_http_conn(500) as conn:
with self.assertRaises(ClientException) as raised:
direct_client.direct_post_object(
self.node, self.part, self.account, self.container,
self.obj, headers)
self.assertEqual(conn.host, self.node['ip'])
self.assertEqual(conn.port, self.node['port'])
self.assertEqual(conn.method, 'POST')
self.assertEqual(conn.path, self.obj_path)
for header in headers:
self.assertEqual(conn.req_headers[header], headers[header])
self.assertEqual(conn.req_headers['user-agent'], self.user_agent)
self.assertTrue('x-timestamp' in conn.req_headers)
self.assertEqual(raised.exception.http_status, 500)
self.assertTrue('POST' in str(raised.exception))
开发者ID:jgmerritt,项目名称:swift,代码行数:19,代码来源:test_direct_client.py
示例5: run_quarantine_zero_byte_post
def run_quarantine_zero_byte_post(self):
container = "container-zbyte-%s" % uuid4()
obj = "object-zbyte-%s" % uuid4()
onode, opart, data_file = self._setup_data_file(container, obj, "DATA")
metadata = read_metadata(data_file)
unlink(data_file)
with open(data_file, "w") as fpointer:
write_metadata(fpointer, metadata)
try:
headers = {
"X-Object-Meta-1": "One",
"X-Object-Meta-Two": "Two",
"X-Backend-Storage-Policy-Index": self.policy.idx,
}
direct_client.direct_post_object(
onode, opart, self.account, container, obj, headers=headers, conn_timeout=1, response_timeout=1
)
raise Exception("Did not quarantine object")
except ClientException as err:
self.assertEquals(err.http_status, 404)
开发者ID:heemanshu,项目名称:swift_juno,代码行数:21,代码来源:test_object_failures.py
示例6: test_direct_post_object_error
def test_direct_post_object_error(self):
headers = {'Key': 'value'}
with mocked_http_conn(500) as conn:
try:
direct_client.direct_post_object(
self.node, self.part, self.account, self.container,
self.obj, headers)
except ClientException as err:
pass
else:
self.fail('ClientException not raised')
self.assertEqual(conn.method, 'POST')
self.assertEqual(conn.path, self.obj_path)
for header in headers:
self.assertEqual(conn.req_headers[header], headers[header])
self.assertEqual(conn.req_headers['user-agent'], self.user_agent)
self.assertTrue('x-timestamp' in conn.req_headers)
self.assertEqual(err.http_status, 500)
self.assertTrue('POST' in str(err))
开发者ID:aureliengoulon,项目名称:swift,代码行数:21,代码来源:test_direct_client.py
示例7: run_quarantine_zero_byte_post
def run_quarantine_zero_byte_post(self):
container = "container-zbyte-%s" % uuid4()
obj = "object-zbyte-%s" % uuid4()
onode, opart, data_file = self._setup_data_file(container, obj, "DATA")
with open(data_file) as fpointer:
metadata = read_metadata(fpointer)
unlink(data_file)
with open(data_file, "w") as fpointer:
write_metadata(fpointer, metadata)
try:
direct_client.direct_post_object(
onode,
opart,
self.account,
container,
obj,
{"X-Object-Meta-1": "One", "X-Object-Meta-Two": "Two"},
conn_timeout=1,
response_timeout=1,
)
raise Exception("Did not quarantine object")
except client.ClientException as err:
self.assertEquals(err.http_status, 404)
开发者ID:Dieterbe,项目名称:swift,代码行数:24,代码来源:test_object_failures.py
注:本文中的swift.common.direct_client.direct_post_object函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论