Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hive/tests_api
1 result
Show changes
Commits on Source (7)
[ []
{ \ No newline at end of file
"about": "To highlight true Gems of Hive community with User Retention as primary objective.",
"admins": [
"bluemist"
],
"avatar_url": "",
"context": {},
"created_at": "2020-02-26 11:33:33",
"id": 1369030,
"is_nsfw": false,
"lang": "en",
"name": "hive-148441",
"num_authors": 1706,
"num_pending": 11787,
"subskrajbers": 5513,
"sum_pending": 13549,
"title": "GEMS",
"type_id": 1,
"seriously": "it does not detect differences"
}
]
\ No newline at end of file
...@@ -215,6 +215,8 @@ ...@@ -215,6 +215,8 @@
marks: marks:
- patterntest - patterntest
- failing
- xfail # no results (underlying functionality is not working)
includes: includes:
- !include common.yaml - !include common.yaml
...@@ -244,6 +246,8 @@ ...@@ -244,6 +246,8 @@
marks: marks:
- patterntest - patterntest
- failing
- xfail # no results (underlying functionality is not working)
includes: includes:
- !include common.yaml - !include common.yaml
...@@ -363,7 +367,7 @@ ...@@ -363,7 +367,7 @@
test_name: Hivemind bridge_api.list_communities patterns test test_name: Hivemind bridge_api.list_communities patterns test
marks: marks:
- patterntest # no nonempty result possible for 5mln set (ABW: something fishy here - as long as pattern is JSON it doesn't care about the content) - patterntest # no nonempty result possible for 5mln set
includes: includes:
- !include common.yaml - !include common.yaml
......
...@@ -328,8 +328,6 @@ ...@@ -328,8 +328,6 @@
marks: marks:
- patterntest - patterntest
- failing
- xfail # null result (super slow query response)
includes: includes:
- !include common.yaml - !include common.yaml
...@@ -649,6 +647,8 @@ ...@@ -649,6 +647,8 @@
marks: marks:
- patterntest - patterntest
- failing
- xfail # wrong pattern, wrong test params (empty result)
includes: includes:
- !include common.yaml - !include common.yaml
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
extra_kwargs: extra_kwargs:
method: "list_comments" method: "list_comments"
directory: "database_api_patterns" directory: "database_api_patterns"
ignore_tags: ["id"]
--- ---
test_name: Hivemind database_api.find_comments patterns test test_name: Hivemind database_api.find_comments patterns test
...@@ -58,4 +59,5 @@ ...@@ -58,4 +59,5 @@
function: validate_response:compare_response_with_pattern function: validate_response:compare_response_with_pattern
extra_kwargs: extra_kwargs:
method: "find_comments" method: "find_comments"
directory: "database_api_patterns" directory: "database_api_patterns"
\ No newline at end of file ignore_tags: ["id", "post_id"]
\ No newline at end of file
...@@ -181,8 +181,6 @@ ...@@ -181,8 +181,6 @@
marks: marks:
- patterntest - patterntest
- failing
- xfail # null result (super long query response)
includes: includes:
- !include common.yaml - !include common.yaml
......
...@@ -8,7 +8,7 @@ def json_pretty_string(json_obj): ...@@ -8,7 +8,7 @@ def json_pretty_string(json_obj):
def save_diff(name, diff): def save_diff(name, diff):
""" Save diff to a file """ """ Save diff to a file """
with open(name, 'w') as f: with open(name, 'w') as f:
f.write(str(diff)) f.write(json_pretty_string(diff))
f.write("\n") f.write("\n")
def save_response(file_name, response_json): def save_response(file_name, response_json):
...@@ -64,13 +64,14 @@ def compare_response_with_pattern(response, method=None, directory=None, ignore_ ...@@ -64,13 +64,14 @@ def compare_response_with_pattern(response, method=None, directory=None, ignore_
save_no_response(response_fname, msg) save_no_response(response_fname, msg)
raise PatternDiffException(msg) raise PatternDiffException(msg)
import jsondiff import deepdiff
pattern = load_pattern(directory + "/" + method + PATTERN_FILE_EXT) pattern = load_pattern(directory + "/" + method + PATTERN_FILE_EXT)
if ignore_tags is not None: if ignore_tags is not None:
pattern = remove_tag(pattern, ignore_tags) pattern = remove_tag(pattern, ignore_tags)
pattern_resp_diff = jsondiff.diff(pattern, result) pattern_resp_diff = deepdiff.DeepDiff(pattern, result)
if pattern_resp_diff: if pattern_resp_diff:
save_diff(fname, pattern_resp_diff) pattern_resp_diff_json = pattern_resp_diff.to_json()
save_diff(fname, pattern_resp_diff_json)
save_response(response_fname, result) save_response(response_fname, result)
msg = "Differences detected between response and pattern. Diff saved to {}\n\nDiff:\n{}".format(fname, pattern_resp_diff) msg = "Differences detected between response and pattern. Diff saved to {}\n\nDiff:\n{}".format(fname, pattern_resp_diff_json)
raise PatternDiffException(msg) raise PatternDiffException(msg)