Bug 1381876 - Allow assert_success to be used without an expected value. r?automatedtester
It happens that we receive responses that do not have a body value.
We want to be able to use assert_success with these as well.
MozReview-Commit-ID: B1f0Hn406Nj
--- a/testing/web-platform/tests/webdriver/tests/support/asserts.py
+++ b/testing/web-platform/tests/webdriver/tests/support/asserts.py
@@ -63,26 +63,28 @@ def assert_error(response, error_code):
:param error_code: string value of the expected "error code"
"""
assert response.status == errors[error_code]
assert "value" in response.body
assert response.body["value"]["error"] == error_code
assert isinstance(response.body["value"]["message"], basestring)
assert isinstance(response.body["value"]["stacktrace"], basestring)
-def assert_success(response, value):
+def assert_success(response, value=None):
"""Verify that the provided wdclient.Response instance described a valid
error response as defined by `dfn-send-an-error` and the provided error
code.
- :param response: wdclient.Response instance
- :param value: expected value of the response body
+
+ :param response: wdclient.Response instance.
+ :param value: Expected value of the response body, if any.
+
"""
-
assert response.status == 200
- assert response.body["value"] == value
+ if value is not None:
+ assert response.body["value"] == value
def assert_dialog_handled(session, expected_text):
result = session.transport.send("GET",
"session/%s/alert/text" % session.session_id)
# If there were any existing dialogs prior to the creation of this
# fixture's dialog, then the "Get Alert Text" command will return
# successfully. In that case, the text must be different than that