Skip to content

Commit db36186

Browse files
committed
update test code.
1 parent a3eadee commit db36186

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

tests/integration/test_access_point_public_access_block_client.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,16 @@ def test_access_point_public_access_block(self):
111111

112112
if ap.status == 'enable':
113113
print(f"ap name: {ap.access_point_name}, status: {ap.status}")
114-
del_result = self.client.delete_access_point(oss.DeleteAccessPointRequest(
115-
bucket=bucket_name,
116-
access_point_name=ap.access_point_name,
117-
))
118-
self.assertEqual(del_result.status_code, 204)
119-
print(f"delete_access_point: {ap.access_point_name}")
120-
121-
114+
try:
115+
""""""
116+
del_result = self.client.delete_access_point(oss.DeleteAccessPointRequest(
117+
bucket=bucket_name,
118+
access_point_name=ap.access_point_name,
119+
))
120+
self.assertEqual(del_result.status_code, 204)
121+
print(f"delete_access_point: {ap.access_point_name}")
122+
except:
123+
"""pass"""
122124
num += 1
123125
time.sleep(10)
124126

@@ -225,14 +227,17 @@ def test_access_point_public_access_block_v1(self):
225227
if ap.access_point_name.startswith('ap-test-oss-'):
226228

227229
if ap.status == 'enable':
228-
print(f"ap name: {ap.access_point_name}, status: {ap.status}")
229-
del_result = self.signv1_client.delete_access_point(oss.DeleteAccessPointRequest(
230-
bucket=bucket_name,
231-
access_point_name=ap.access_point_name,
232-
))
233-
self.assertEqual(del_result.status_code, 204)
234-
print(f"delete_access_point: {ap.access_point_name}")
235-
230+
try:
231+
""""""
232+
print(f"ap name: {ap.access_point_name}, status: {ap.status}")
233+
del_result = self.signv1_client.delete_access_point(oss.DeleteAccessPointRequest(
234+
bucket=bucket_name,
235+
access_point_name=ap.access_point_name,
236+
))
237+
self.assertEqual(del_result.status_code, 204)
238+
print(f"delete_access_point: {ap.access_point_name}")
239+
except:
240+
"""pass"""
236241
num += 1
237242
time.sleep(10)
238243

tests/unit/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ def reason(self) -> str:
4141

4242
@property
4343
def content(self) -> bytes:
44+
if self._body is not None:
45+
if not isinstance(self._body, (bytes, str)):
46+
raise TypeError(f"not support type {type(self._body)}")
47+
if isinstance(self._body, str):
48+
return self._body.encode()
4449
return self._body
4550

4651
def __repr__(self) -> str:

tests/unit/models/test_bucket_policy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def test_deserialize_result(self):
137137
status_code=200,
138138
http_response=MockHttpResponse()
139139
)
140-
deserializer = [serde.deserialize_output_xmlbody]
140+
deserializer = []
141141
serde.deserialize_output(result, op_output, custom_deserializer=deserializer)
142142
self.assertEqual('OK', result.status)
143143
self.assertEqual(xml_data, result.body)

tests/unit/models/test_bucket_style.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def test_constructor_result(self):
231231
self.assertEqual('Wed, 20 May 2020 12:07:15 GMT', result.style_list.styles[0].create_time)
232232
self.assertEqual('Wed, 21 May 2020 12:07:15 GMT', result.style_list.styles[0].last_modify_time)
233233
self.assertEqual('image', result.style_list.styles[0].category)
234-
self.assertEqual('example-bucket', result.style_list.styles[1].name)
234+
self.assertEqual('example-bucket2', result.style_list.styles[1].name)
235235
self.assertEqual('image/resize,w_200', result.style_list.styles[1].content)
236236
self.assertEqual('Wed, 20 May 2020 12:08:04 GMT', result.style_list.styles[1].create_time)
237237
self.assertEqual('Wed, 21 May 2020 12:08:04 GMT', result.style_list.styles[1].last_modify_time)

0 commit comments

Comments
 (0)