Skip to content
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

Let `_make_validate` method supports the `list` structures JSON #18

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
3 participants
@asdf2014
Copy link

commented Jan 30, 2019

No description provided.

@coveralls

This comment has been minimized.

Copy link

commented Jan 30, 2019

Coverage Status

Coverage increased (+2.5%) to 77.193% when pulling bfe6aa4 on asdf2014:validate_list into 623db1d on HttpRunner:master.

5 similar comments
@coveralls

This comment has been minimized.

Copy link

commented Jan 30, 2019

Coverage Status

Coverage increased (+2.5%) to 77.193% when pulling bfe6aa4 on asdf2014:validate_list into 623db1d on HttpRunner:master.

@coveralls

This comment has been minimized.

Copy link

commented Jan 30, 2019

Coverage Status

Coverage increased (+2.5%) to 77.193% when pulling bfe6aa4 on asdf2014:validate_list into 623db1d on HttpRunner:master.

@coveralls

This comment has been minimized.

Copy link

commented Jan 30, 2019

Coverage Status

Coverage increased (+2.5%) to 77.193% when pulling bfe6aa4 on asdf2014:validate_list into 623db1d on HttpRunner:master.

@coveralls

This comment has been minimized.

Copy link

commented Jan 30, 2019

Coverage Status

Coverage increased (+2.5%) to 77.193% when pulling bfe6aa4 on asdf2014:validate_list into 623db1d on HttpRunner:master.

@coveralls

This comment has been minimized.

Copy link

commented Jan 30, 2019

Coverage Status

Coverage increased (+2.5%) to 77.193% when pulling bfe6aa4 on asdf2014:validate_list into 623db1d on HttpRunner:master.

{"eq": ["content.{}".format(key), value]}
)
if isinstance(resp_content_json, dict):
for key, value in resp_content_json.items():

This comment has been minimized.

Copy link
@debugtalk

debugtalk Feb 2, 2019

Contributor
if isinstance(value, (dict, list)):
    continue

这一部分还是有必要的,因为假如 value 为 dict/list,已经算是复杂结构体了,保持不变的可能性较小,所以不宜直接将其作为比较项。

This comment has been minimized.

Copy link
@asdf2014

asdf2014 Feb 3, 2019

Author

的确,不过目前我这边用的还没有这个问题 😅

)
elif isinstance(resp_content_json, list):
for i in range(0, len(resp_content_json)):
resp_content_json = resp_content_json[i]

This comment has been minimized.

Copy link
@debugtalk

debugtalk Feb 2, 2019

Contributor

这里有两个问题:
1、重复使用 resp_content_json 这个变量名容易产生混淆,建议对 list 的元素采用不同的变量名;
2、你这里假设 list 始终是 [{a:a},{b:b},...] 的形式,那假如出现 [{a:a},b,...] 的情况就会出现问题。

This comment has been minimized.

Copy link
@asdf2014

asdf2014 Feb 3, 2019

Author

是的,想要通用的话,还是要多考虑一下这块,期待后续 validator 支持 jmespath 的语法~~

@debugtalk

This comment has been minimized.

Copy link
Contributor

commented Feb 3, 2019

@asdf2014 我先将这个PR关闭了哈,后面会更新为 jmespath 语法。

@debugtalk debugtalk closed this Feb 3, 2019

@asdf2014 asdf2014 deleted the asdf2014:validate_list branch Feb 3, 2019

@asdf2014

This comment has been minimized.

Copy link
Author

commented Feb 3, 2019

@debugtalk 嗯呢,期待下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.