-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1. add random test bucket name 2. add delete test file after finish 3… #173
base: master
Are you sure you want to change the base?
Conversation
…. add tagging function&tests
|
""" | ||
|
||
:param str key: 上传tagging的对象名称,不能为空。 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1、注释最好用英文
2、参数input最好能换一个有意义的,比如 tagBody
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注释这里 沿用的之前的风格,参数名称我换下
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1、需要对key是否为空进行合法性检查
2、需要对data进行合法性检查,是否是一个ObjectTagging对象
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1、key为空,现在所有接口都没有判断
2、参数类型也不用,如果不是这个类型,后面访问类中变量或方法时会报异常
|
||
_MAX_OBJECT_TAGGING_KEY_LENGTH=128 | ||
_MAX_OBJECT_TAGGING_VALUE_LENGTH=256 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些常量定义有统一地方放吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
写的时候也在想这个事,但是好像没有统一定义的地方
|
||
if key is None or key == '': | ||
raise ClientError("ObjectTagging key should not be empty") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value为空是否需要校验一下?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后端接受value为空的情况
rule = LifecycleRule( | ||
_find_tag(rule_node, 'ID'), | ||
_find_tag(rule_node, 'Prefix'), | ||
status=_find_tag(rule_node, 'Status'), | ||
expiration=expiration, | ||
abort_multipart_upload=abort_multipart_upload, | ||
storage_transitions=storage_transitions | ||
storage_transitions=storage_transitions, | ||
tagging=tagging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
两个变量名怎么是一样的?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff 结果应该符合预期吧
@@ -567,6 +584,13 @@ def to_put_bucket_lifecycle(bucket_lifecycle): | |||
_add_text_child(storage_transition_node, 'CreatedBeforeDate', | |||
date_to_iso8601(storage_transition.created_before_date)) | |||
|
|||
tagging = rule.tagging | |||
if tagging: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tagging是bool类型吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete 接口的返回值 是否需要定义为 ObjectTagging ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里写的有问题,我改下
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要确认一下,在lifecycle 里, key 和value 是否受 url_encoded 标志位的影响。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
和后端开发同学确认,有关tagging的返回,在body里面都不会 urlencode,这里的代码我改下
result = self.bucket.get_object_tagging(key+'_test') | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要增加 断点上传 + tagging 的测试用例。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已添加
1、add random test bucket name
2、delete test file after tests finish
3、add tagging function&tests