Skip to content

Conversation

@PaulBrandUWV
Copy link
Contributor

This Pull request adds a keyword to get the response from the last request.
The keyword can be used to create much cleaner testcases because the response does not have to be stored to a variable in the test case.

Example:

*** Settings ***
Library     RequestsLibrary

*** Variables ***
${url}    https://httpbin.org/base64
${data}    anlmhcrh7853r042yqtx7rhaohfx,jr0aofds*&*^$IHLFEMXhkdjsxhcc
${base64_data}    YW5sbWhjcmg3ODUzcjA0MnlxdHg3cmhhb2hmeCxqcjBhb2ZkcyomKl4kSUhMRkVNWGhrZGpzeGhjYw==

*** Keywords ***
Response body equals
    [Arguments]    ${data}
    ${response}=   Get response
    Should be equal    ${response.text}    ${data}

*** Test cases ***
httpbin base64 decode
    When get  ${url}/${base64_data}
    Then response body equals    ${data}

This PR also removes some skipif decorators from the unit tests for old python versions.

@codecov
Copy link

codecov bot commented Jun 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.93%. Comparing base (6899855) to head (ea64dd3).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #397      +/-   ##
==========================================
+ Coverage   85.29%   88.93%   +3.64%     
==========================================
  Files           9        9              
  Lines         476      479       +3     
  Branches       49       49              
==========================================
+ Hits          406      426      +20     
+ Misses         65       51      -14     
+ Partials        5        2       -3     
Flag Coverage Δ
acceptance 85.38% <100.00%> (+0.09%) ⬆️
unit 60.12% <66.66%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@PaulBrandUWV
Copy link
Contributor Author

@lucagiove what do you think?

@lucagiove
Copy link
Member

It's an interesting keyword I'm wondering whether the name of the keyword might be more clear, maybe something like "Last Response" ? It's a concept that already exist in the code.
Also because get might be confused with GET http method.

@PaulBrandUWV
Copy link
Contributor Author

Makes sense! I renamed the keyword. The class method can not be "last_response" since that name already exists in scope.

Removes some skipif decorators from the unit tests for old python versions
@lucagiove lucagiove merged commit b893b46 into MarketSquare:master Nov 7, 2024
8 checks passed
@PaulBrandUWV
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants