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

Optimize error message #404

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions atests/test_requests.robot
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ Get Request And Fail By Default On Http Error

Get Request And Fail By Expecting A 200 Status
[Tags] get
Run Keyword And Expect Error Url: ${HTTP_LOCAL_SERVER}/status/404?param Expected status: 404 != 200
Run Keyword And Expect Error Url: ${HTTP_LOCAL_SERVER}/status/404?param Expected status: 200 != 404
... GET ${HTTP_LOCAL_SERVER}/status/404 param 200

Get Request And Fail By Expecting A 200 Status With A Message
[Tags] get
Run Keyword And Expect Error Custom msg Url: ${HTTP_LOCAL_SERVER}/status/404?param Expected status: 404 != 200
Run Keyword And Expect Error Custom msg Url: ${HTTP_LOCAL_SERVER}/status/404?param Expected status: 200 != 404
... GET ${HTTP_LOCAL_SERVER}/status/404 param 200 Custom msg

Get Request Expect An Error And Evaluate Response
Expand Down
4 changes: 2 additions & 2 deletions atests/test_requests_on_session.robot
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ Get Request And Fail By Default On Http Error

Get Request And Fail By Expecting A 200 Status
[Tags] get
Run Keyword And Expect Error Url: ${HTTP_LOCAL_SERVER}/status/404?param Expected status: 404 != 200
Run Keyword And Expect Error Url: ${HTTP_LOCAL_SERVER}/status/404?param Expected status: 200 != 404
... GET On Session ${GLOBAL_SESSION} /status/404 param 200

Get Request And Fail By Expecting A 200 Status With A Message
[Tags] get
Run Keyword And Expect Error Custom msg Url: ${HTTP_LOCAL_SERVER}/status/404?param Expected status: 404 != 200
Run Keyword And Expect Error Custom msg Url: ${HTTP_LOCAL_SERVER}/status/404?param Expected status: 200 != 404
... GET On Session ${GLOBAL_SESSION} /status/404 param 200 Custom msg

Get Request Expect An Error And Evaluate Response
Expand Down
8 changes: 4 additions & 4 deletions atests/test_status_assertions.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Request And Status Should Be Different
[Tags] get status
${resp}= GET On Session ${GLOBAL_SESSION} /status/404 expected_status=any
Run Keyword And Expect Error
... Url: ${HTTP_LOCAL_SERVER}/status/404 Expected status: 404 != 201
... Url: ${HTTP_LOCAL_SERVER}/status/404 Expected status: 201 != 404
... Status Should Be
... 201
... ${resp}
Expand Down Expand Up @@ -36,7 +36,7 @@ Request And Status Should Be With A Message
[Tags] get status
${resp}= GET On Session ${GLOBAL_SESSION} /status/418 expected_status=any
Run Keyword And Expect Error
... It should be a teapot! Url: ${HTTP_LOCAL_SERVER}/status/418 Expected status: 418 != 200
... It should be a teapot! Url: ${HTTP_LOCAL_SERVER}/status/418 Expected status: 200 != 418
... Status Should Be
... OK
... ${resp}
Expand Down Expand Up @@ -89,7 +89,7 @@ Assert Status Should Be Fail On The Last Request
[Tags] post status
POST On Session ${GLOBAL_SESSION} /status/500 expected_status=500
Run Keyword And Expect Error
... Url: ${HTTP_LOCAL_SERVER}/status/500 Expected status: 500 != 200
... Url: ${HTTP_LOCAL_SERVER}/status/500 Expected status: 200 != 500
... Status Should Be
... OK

Expand Down Expand Up @@ -124,6 +124,6 @@ Assert Status Should Be Fail On The Last Session-Less Request
[Tags] post status
POST ${HTTP_LOCAL_SERVER}/status/500 expected_status=500
Run Keyword And Expect Error
... Url: ${HTTP_LOCAL_SERVER}/status/500 Expected status: 500 != 200
... Url: ${HTTP_LOCAL_SERVER}/status/500 Expected status: 200 != 500
... Status Should Be
... OK
2 changes: 1 addition & 1 deletion src/RequestsLibrary/SessionKeywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def _check_status(expected_status, resp, msg=None):
expected_status = utils.parse_named_status(expected_status)
msg = "" if msg is None else "{} ".format(msg)
msg = "{}Url: {} Expected status".format(msg, resp.url)
assert_equal(resp.status_code, expected_status, msg)
assert_equal(expected_status, resp.status_code, msg)

def _get_timeout(self, timeout):
result = timeout if timeout is not None else self.timeout
Expand Down