Skip to content

Commit

Permalink
Fix missing rebased data
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
michaelboulton committed Mar 2, 2019
1 parent 5062d6f commit c2225b4
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 4 deletions.
6 changes: 5 additions & 1 deletion tavern/_plugins/mqtt/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ def _await_response(self):

msg.payload = msg.payload.decode("utf8")

self.test_block_config["tavern_internal"]["pytest_hook_caller"].pytest_tavern_log_response(response=get_paho_mqtt_response_information(msg))
self.test_block_config["tavern_internal"][
"pytest_hook_caller"
].pytest_tavern_log_response(
response=get_paho_mqtt_response_information(msg)
)

if json_payload:
try:
Expand Down
10 changes: 8 additions & 2 deletions tavern/_plugins/rest/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def enc(v):
log_dict_block(response_info["headers"], "Headers")
log_dict_block(response_info["body"], "Body")
if response_info.get("redirect_query_location"):
log_dict_block(response_info["redirect_query_location"], "Redirect location")
log_dict_block(
response_info["redirect_query_location"], "Redirect location"
)

def _get_redirect_query_params_with_err_check(self, response):
"""Call get_redirect_query_params, but also trigger an error if we
Expand Down Expand Up @@ -156,7 +158,11 @@ def verify(self, response):
"""
self._verbose_log_response(response)

self.test_block_config["tavern_internal"]["pytest_hook_caller"].pytest_tavern_log_response(response=get_requests_response_information(response))
self.test_block_config["tavern_internal"][
"pytest_hook_caller"
].pytest_tavern_log_response(
response=get_requests_response_information(response)
)

self.response = response
self.status_code = response.status_code
Expand Down
2 changes: 1 addition & 1 deletion tavern/_plugins/rest/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_redirect_query_params(response):
else:
parsed = urlparse(redirect_url)
qp = parsed.query
redirect_query_params = {i:j[0] for i, j in parse_qs(qp).items()}
redirect_query_params = {i: j[0] for i, j in parse_qs(qp).items()}

return redirect_query_params

Expand Down
1 change: 1 addition & 0 deletions tavern/testutils/newhooks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pylint: disable=unused-argument


def pytest_tavern_log_response(response):
"""Called when a response is obtained from a server
Expand Down
7 changes: 7 additions & 0 deletions tavern/testutils/pytesthook/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ def pytest_collect_file(parent, path):
return YamlFile(path, parent)

return None


def pytest_addhooks(pluginmanager):
"""Add our custom tavern hooks"""
from . import newhooks

pluginmanager.add_hookspecs(newhooks)
2 changes: 2 additions & 0 deletions tavern/testutils/pytesthook/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def runtest(self):

load_plugins(self.global_cfg)

self.global_cfg["tavern_internal"] = {"pytest_hook_caller": self.config.hook}

# INTERNAL
# NOTE - now that we can 'mark' tests, we could use pytest.mark.xfail
# instead. This doesn't differentiate between an error in verification
Expand Down
21 changes: 21 additions & 0 deletions tavern/testutils/pytesthook/newhooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# pylint: disable=unused-argument


def pytest_tavern_log_response(response):
"""Called when a response is obtained from a server
Todo:
This just takes 'response' at the moment, will need to be expanded to
take the filename and the test name/stage name as well.
"""


def pytest_tavern_before_request(stage):
"""Called before each request"""


def pytest_tavern_after_request(stage):
"""Called after each request, even if it fails
Note:
Some types of stages can run the request successfully, then fail later
on during verification.
"""

0 comments on commit c2225b4

Please sign in to comment.