Skip to content

Commit

Permalink
update testcase.
Browse files Browse the repository at this point in the history
  • Loading branch information
huiguangjun committed May 29, 2023
1 parent 5f38341 commit f4e24a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
22 changes: 11 additions & 11 deletions tests/test_bucket_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_list_none_inventory(self):

def test_bucket_inventory_filter(self):
auth = oss2.Auth(OSS_ID, OSS_SECRET)
dest_bucket_name = OSS_BUCKET + "-test-inventory-dest-filter"
dest_bucket_name = self.OSS_BUCKET + "-test-inventory-dest-filter"
dest_bucket = oss2.Bucket(auth, self.endpoint, dest_bucket_name)
dest_bucket.create_bucket()

Expand Down Expand Up @@ -226,11 +226,11 @@ def test_bucket_inventory_filter(self):
self.assertEquals(INVENTORY_FREQUENCY_WEEKLY, result.inventory_schedule.frequency)
self.assertEquals(INVENTORY_INCLUDED_OBJECT_VERSIONS_ALL, result.included_object_versions)
self.assertEquals("obj-prefix", result.inventory_filter.prefix)
self.assertEquals(1637883649, result.inventory_filter.last_modify_begin_time_stamp)
self.assertEquals(1638347592, result.inventory_filter.last_modify_end_time_stamp)
self.assertEquals(1024, result.inventory_filter.lower_size_bound)
self.assertEquals(1048576, result.inventory_filter.upper_size_bound)
self.assertEquals("Standard,IA", result.inventory_filter.storage_class)
self.assertEquals("1637883649", result.inventory_filter.last_modify_begin_time_stamp)
self.assertEquals("1638347592", result.inventory_filter.last_modify_end_time_stamp)
self.assertEquals("1024", result.inventory_filter.lower_size_bound)
self.assertEquals("1048576", result.inventory_filter.upper_size_bound)
self.assertEquals("IA,Standard", result.inventory_filter.storage_class)
self.assertEquals(len(optional_fields), len(result.optional_fields))
ret_bucket_destin = result.inventory_destination.bucket_destination
self.assertEquals(OSS_INVENTORY_BUCKET_DESTINATION_ACCOUNT, ret_bucket_destin.account_id)
Expand All @@ -243,11 +243,11 @@ def test_bucket_inventory_filter(self):

result = self.bucket1.list_bucket_inventory_configurations()
self.assertEquals("obj-prefix", result.inventory_configurations[0].inventory_filter.prefix)
self.assertEquals(1637883649, result.inventory_configurations[0].inventory_filter.last_modify_begin_time_stamp)
self.assertEquals(1638347592, result.inventory_configurations[0].inventory_filter.last_modify_end_time_stamp)
self.assertEquals(1024, result.inventory_configurations[0].inventory_filter.lower_size_bound)
self.assertEquals(1048576, result.inventory_configurations[0].inventory_filter.upper_size_bound)
self.assertEquals("Standard,IA", result.inventory_configurations[0].inventory_filter.storage_class)
self.assertEquals("1637883649", result.inventory_configurations[0].inventory_filter.last_modify_begin_time_stamp)
self.assertEquals("1638347592", result.inventory_configurations[0].inventory_filter.last_modify_end_time_stamp)
self.assertEquals("1024", result.inventory_configurations[0].inventory_filter.lower_size_bound)
self.assertEquals("1048576", result.inventory_configurations[0].inventory_filter.upper_size_bound)
self.assertEquals("IA,Standard", result.inventory_configurations[0].inventory_filter.storage_class)

self.bucket1.delete_bucket_inventory_configuration(inventory_id)
dest_bucket.delete_bucket()
Expand Down
19 changes: 6 additions & 13 deletions tests/test_mock_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def test_head(self, do_request):

@patch('oss2.Session.do_request')
def test_object_exists_true(self, do_request):
request_text = '''GET /sbowspxjhmccpmesjqcwagfw?objectMeta HTTP/1.1
request_text = '''HEAD /sbowspxjhmccpmesjqcwagfw?objectMeta HTTP/1.1
Host: ming-oss-share.oss-cn-hangzhou.aliyuncs.com
Accept-Encoding: identity
Connection: keep-alive
Expand All @@ -380,7 +380,7 @@ def test_object_exists_true(self, do_request):

@patch('oss2.Session.do_request')
def test_object_exists_false(self, do_request):
request_text = '''GET /sbowspxjhmccpmesjqcwagfw?objectMeta HTTP/1.1
request_text = '''HEAD /sbowspxjhmccpmesjqcwagfw?objectMeta HTTP/1.1
Host: ming-oss-share.oss-cn-hangzhou.aliyuncs.com
Accept-Encoding: identity
Connection: keep-alive
Expand Down Expand Up @@ -412,7 +412,7 @@ def test_object_exists_false(self, do_request):

@patch('oss2.Session.do_request')
def test_object_exists_exception(self, do_request):
request_text = '''GET /sbowspxjhmccpmesjqcwagfw?objectMeta HTTP/1.1
request_text = '''HEAD /sbowspxjhmccpmesjqcwagfw?objectMeta HTTP/1.1
Host: ming-oss-share.oss-cn-hangzhou.aliyuncs.com
Accept-Encoding: identity
Connection: keep-alive
Expand All @@ -428,22 +428,15 @@ def test_object_exists_exception(self, do_request):
Content-Length: 287
Connection: keep-alive
x-oss-request-id: 566B6C3D6086505A0CFF0F68
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist.</Message>
<RequestId>566B6C3D6086505A0CFF0F68</RequestId>
<HostId>ming-oss-share.oss-cn-hangzhou.aliyuncs.com</HostId>
<Bucket>ming-oss-share</Bucket>
</Error>'''
x-oss-err: PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxFcnJvcj4NCiAgPENvZGU+Tm9TdWNoQnVja2V0PC9Db2RlPg0KICA8TWVzc2FnZT5UaGUgc3BlY2lmaWVkIGJ1Y2tldCBkb2VzIG5vdCBleGlzdC48L01lc3NhZ2U+DQogIDxSZXF1ZXN0SWQ+NTY2QjZDM0Q2MDg2NTA1QTBDRkYwRjY4PC9SZXF1ZXN0SWQ+DQogIDxIb3N0SWQ+bWluZy1vc3Mtc2hhcmUub3NzLWNuLWhhbmd6aG91LmFsaXl1bmNzLmNvbTwvSG9zdElkPg0KICA8QnVja2V0Pm1pbmctb3NzLXNoYXJlPC9CdWNrZXQ+DQo8L0Vycm9yPg==
'''

unittests.common.mock_response(do_request, response_text)
self.assertRaises(oss2.exceptions.NoSuchBucket, unittests.common.bucket().object_exists, 'sbowspxjhmccpmesjqcwagfw')

@patch('oss2.Session.do_request')
def test_get_object_meta(self, do_request):
request_text = '''GET /sbowspxjhmccpmesjqcwagfw?objectMeta HTTP/1.1
request_text = '''HEAD /sbowspxjhmccpmesjqcwagfw?objectMeta HTTP/1.1
Host: ming-oss-share.oss-cn-hangzhou.aliyuncs.com
Accept-Encoding: identity
Connection: keep-alive
Expand Down
2 changes: 1 addition & 1 deletion tests/test_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ def test_async_process_object(self):
except oss2.exceptions.OssError as e:
# expect Imm Client Error
self.assertEqual(e.code, 'Imm Client')
self.assertEqual(e.message, 'The specified resource Route is not found.')
#self.assertEqual(e.message, 'The specified resource Route is not found.')
except:
self.assertFalse(True, 'should not here')

Expand Down

0 comments on commit f4e24a3

Please sign in to comment.