This repository was archived by the owner on Jun 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Let _make_validate
method supports the list
structures JSON
#18
Closed
+14
−12
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
except ImportError: | ||
JSONDecodeError = ValueError | ||
|
||
|
||
IGNORE_REQUEST_HEADERS = [ | ||
"host", | ||
"accept", | ||
|
@@ -183,7 +182,7 @@ def _make_request_data(self, teststep_dict, entry_json): | |
# post_data = utils.x_www_form_urlencoded(post_data) | ||
pass | ||
else: | ||
#TODO: make compatible with more mimeType | ||
# TODO: make compatible with more mimeType | ||
pass | ||
|
||
teststep_dict["request"][request_data_key] = post_data | ||
|
@@ -252,16 +251,18 @@ def _make_validate(self, teststep_dict, entry_json): | |
else: | ||
resp_content_json = json.loads(text) | ||
|
||
if not isinstance(resp_content_json, dict): | ||
return | ||
|
||
for key, value in resp_content_json.items(): | ||
if isinstance(value, (dict, list)): | ||
continue | ||
|
||
teststep_dict["validate"].append( | ||
{"eq": ["content.{}".format(key), value]} | ||
) | ||
if isinstance(resp_content_json, dict): | ||
for key, value in resp_content_json.items(): | ||
teststep_dict["validate"].append( | ||
{"eq": ["content.{}".format(key), value]} | ||
) | ||
elif isinstance(resp_content_json, list): | ||
for i in range(0, len(resp_content_json)): | ||
resp_content_json = resp_content_json[i] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 是的,想要通用的话,还是要多考虑一下这块,期待后续 validator 支持 jmespath 的语法~~ |
||
for key, value in resp_content_json.items(): | ||
teststep_dict["validate"].append( | ||
{"eq": ["content.{}.{}".format(i, key), value]} | ||
) | ||
|
||
def _prepare_teststep(self, entry_json): | ||
""" extract info from entry dict and make teststep | ||
|
@@ -318,6 +319,7 @@ def _prepare_teststeps(self, testcase): | |
teststeps list are parsed from HAR log entries list. | ||
""" | ||
|
||
def is_exclude(url, exclude_str): | ||
exclude_str_list = exclude_str.split("|") | ||
for exclude_str in exclude_str_list: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 为 dict/list,已经算是复杂结构体了,保持不变的可能性较小,所以不宜直接将其作为比较项。
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.
的确,不过目前我这边用的还没有这个问题 😅