1. add random test bucket name 2. add delete test file after finish 3…#173
1. add random test bucket name 2. add delete test file after finish 3…#173coderall wants to merge 4 commits intoaliyun:masterfrom coderall:master
Conversation
…. add tagging function&tests
|
|
| """ | ||
|
|
||
| :param str key: 上传tagging的对象名称,不能为空。 | ||
|
|
There was a problem hiding this comment.
1、注释最好用英文
2、参数input最好能换一个有意义的,比如 tagBody
There was a problem hiding this comment.
注释这里 沿用的之前的风格,参数名称我换下
| headers = http.CaseInsensitiveDict(headers) | ||
|
|
||
| data = self.__convert_data(ObjectTagging, xml_utils.to_put_object_tagging, input) | ||
| resp = self.__do_object('PUT', key, data=data, params={Bucket.TAGGING: ''}, headers=headers) |
There was a problem hiding this comment.
1、需要对key是否为空进行合法性检查
2、需要对data进行合法性检查,是否是一个ObjectTagging对象
There was a problem hiding this comment.
1、key为空,现在所有接口都没有判断
2、参数类型也不用,如果不是这个类型,后面访问类中变量或方法时会报异常
|
|
||
| _MAX_OBJECT_TAGGING_KEY_LENGTH=128 | ||
| _MAX_OBJECT_TAGGING_VALUE_LENGTH=256 | ||
|
|
There was a problem hiding this comment.
写的时候也在想这个事,但是好像没有统一定义的地方
|
|
||
| if key is None or key == '': | ||
| raise ClientError("ObjectTagging key should not be empty") | ||
|
|
| abort_multipart_upload=abort_multipart_upload, | ||
| storage_transitions=storage_transitions | ||
| storage_transitions=storage_transitions, | ||
| tagging=tagging |
| date_to_iso8601(storage_transition.created_before_date)) | ||
|
|
||
| tagging = rule.tagging | ||
| if tagging: |
There was a problem hiding this comment.
python的语法习惯,这里tagging是ObjectTagging类型
oss2/api.py
Outdated
| def delete_object_tagging(self, key): | ||
| """ | ||
| :param str key: 要删除tagging的对象名称 | ||
| :return: :class:`ObjectTagging <oss2.models.ObjectTagging>` |
There was a problem hiding this comment.
delete 接口的返回值 是否需要定义为 ObjectTagging ?
oss2/xml_utils.py
Outdated
| tagging_rule = ObjectTaggingRule() | ||
| for tag_node in lifecycle_tagging_nodes: | ||
| key = _find_object(tag_node, 'Key', url_encoded) | ||
| value = _find_object(tag_node, 'Value', url_encoded) |
There was a problem hiding this comment.
需要确认一下,在lifecycle 里, key 和value 是否受 url_encoded 标志位的影响。
There was a problem hiding this comment.
和后端开发同学确认,有关tagging的返回,在body里面都不会 urlencode,这里的代码我改下
| self.assertEqual(2, result.tag_set.len()) | ||
| self.assertEqual('中文', result.tag_set.tagging_rule[' +/ ']) | ||
| self.assertEqual('test++/', result.tag_set.tagging_rule['中文']) | ||
|
|
There was a problem hiding this comment.
需要增加 断点上传 + tagging 的测试用例。
1、add random test bucket name
2、delete test file after tests finish
3、add tagging function&tests