Skip to content

Commit fec41ff

Browse files
authored
Merge pull request #309 from MarketSquare/0.8
"Lock down" 0.8 release on the go... smile
2 parents 5902b61 + 46955d3 commit fec41ff

36 files changed

+3122
-1494
lines changed

.github/workflows/pythonapp.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,25 @@ jobs:
4646
coverage report
4747
coverage xml
4848
- name: Update codecov for unit tests
49-
uses: codecov/codecov-action@v1.0.6
49+
uses: codecov/codecov-action@v1
5050
with:
5151
flags: unit
5252
file: coverage.xml
5353
- name: Test with Robot Framework and coverage
5454
run: |
5555
coverage erase
56-
coverage run --branch --source src/ -m robot --exclude skip --pythonpath src --outputdir ./tests-report --consolecolors ansi atests
56+
coverage run --branch --source src/ -m robot --loglevel trace:info --exclude skip --pythonpath src --outputdir ./tests-report --consolecolors ansi atests
5757
- name: Acceptance tests coverage
5858
run: |
5959
coverage report
6060
coverage xml
6161
- name: Update codecov for acceptance tests
62-
uses: codecov/codecov-action@v1.0.6
62+
uses: codecov/codecov-action@v1
6363
with:
6464
flags: acceptance
6565
file: coverage.xml
6666
- name: Archive Robot Framework Tests Report
67+
if: ${{ always() }}
6768
uses: actions/upload-artifact@v1
6869
with:
6970
name: rf-tests-report-${{ matrix.os }}-${{ matrix.python-version }}

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ Test coverage is evaluated for unit and acceptance tests, after test execution
4646

4747
#### Documentation
4848

49-
Keywords documentation can be updated running the following command:
49+
Keywords documentation (on Linux) can be updated running the following script:
5050

51-
`python -m robot.libdoc src/RequestsLibrary doc/RequestsLibrary.html`
51+
`doc/generate_doc.sh`
5252

5353
# What can I do?
5454

README.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,15 @@
33
[![PyPi downloads](https://img.shields.io/pypi/dm/robotframework-requests.svg)](https://pypi.python.org/pypi/robotframework-requests)
44
[![Latest Version](https://img.shields.io/pypi/v/robotframework-requests.svg)](https://pypi.python.org/pypi/robotframework-requests)
55

6-
🏠 ``RequestsLibrary`` is a [Robot Framework](https://robotframework.org/) test library that uses the [Requests](https://github.com/kennethreitz/requests) HTTP client.
6+
🏠 ``RequestsLibrary`` is a [Robot Framework](https://robotframework.org/) library
7+
aimed to provide HTTP api testing functionalities by wrapping the well known [Python Requests Library](https://github.com/kennethreitz/requests).
78

89

910
## Install stable version
1011
```sh
1112
pip install robotframework-requests
1213
```
1314

14-
## ✨ Install latest 0.8 pre-release version (recommended) ✨
15-
```sh
16-
pip install robotframework-requests --pre
17-
```
18-
- [0.8 README](https://github.com/MarketSquare/robotframework-requests/blob/0.8/README.md)
19-
- [0.8 Keywords documentation](https://robotframework-requests.netlify.app/doc/requestslibrary)
20-
2115
### What's new in 0.8
2216

2317
**New keywords structure:**
@@ -28,7 +22,8 @@ when a session is not needed.
2822

2923
**Implicit assert on status code:**
3024
`* On Session` keywords automatically fail if an error status code is returned.
31-
`expect_status=` could be used to specify a status code (`201`, `OK`, `Bad request`) or `any` if you want to evaluate the response in any case.
25+
`expect_status=` could be used to specify a status code (`201`, `OK`, `Bad request`)
26+
or `any` if you want to evaluate the response in any case.
3227

3328
**Closer to the original Requests library:**
3429
New keywords have the same parameter orders and structure as the original.
@@ -43,18 +38,27 @@ Main keywords file has been split with a more logic division to allow better and
4338
Library Collections
4439
Library RequestsLibrary
4540
41+
Suite Setup Create Session jsonplaceholder https://jsonplaceholder.typicode.com
42+
4643
*** Test Cases ***
47-
Get Request
48-
Create Session jsonplaceholder https://jsonplaceholder.typicode.com
49-
${resp}= Get request jsonplaceholder /posts/1
50-
Dictionary Should Contain Value ${resp.json()} sunt aut facere repellat provident occaecati excepturi
51-
52-
Post Request
53-
Create Session jsonplaceholder https://jsonplaceholder.typicode.com
54-
&{data}= Create dictionary title=Robotframework requests body=This is a test! userId=1
55-
${resp}= Post request jsonplaceholder /posts json=${data}
56-
Dictionary Should Contain Key ${resp.json()} id
44+
45+
Get Request Test
46+
Create Session google http://www.google.com
47+
48+
${resp_google}= GET On Session google / expected_status=200
49+
${resp_json}= GET On Session jsonplaceholder /posts/1
50+
51+
Should Be Equal As Strings ${resp_google.reason} OK
52+
Dictionary Should Contain Value ${resp_json.json()} sunt aut facere repellat provident occaecati excepturi optio reprehenderit
53+
54+
Post Request Test
55+
&{data}= Create dictionary title=Robotframework requests body=This is a test! userId=1
56+
${resp}= POST On Session jsonplaceholder /posts json=${data}
57+
58+
Status Should Be 201 ${resp}
59+
Dictionary Should Contain Key ${resp.json()} id
5760
```
61+
5862
### 📖 Keywords documentation
5963
Robotframework-requests offers a wide set of keywords which can be found in the [Keywords documentation](http://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html)
6064

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
*** Settings ***
2+
Library Collections
3+
Library RequestsLibrary
4+
Resource res_setup.robot
5+
6+
Suite Setup Run Keywords Setup Flask Http Server
7+
... Setup Response For Json Tests
8+
Suite Teardown Teardown Flask Http Server And Sessions
9+
10+
*** Variables ***
11+
${resp} created in the setup
12+
&{dict_params} key_one=true key_two=this is a test string
13+
14+
*** Test Cases ***
15+
16+
Do Not Pretty Print a JSON object
17+
[Tags] json
18+
${jsondata}= To Json ${resp.content}
19+
Dictionaries Should Be Equal ${jsondata['args']} ${dict_params}
20+
21+
Pretty Print a JSON object
22+
[Tags] json
23+
Comment Define json variable.
24+
${output}= To Json ${resp.content} pretty_print=True
25+
Should Contain ${output} "key_one": "true"
26+
Should Contain ${output} "key_two": "this is a test string"
27+
Should Not Contain ${output} {u'key_two': u'this is a test string', u'key_one': u'true'}
28+
29+
Set Pretty Print to non-Boolean value
30+
[Tags] json
31+
Comment Define json variable.
32+
${output}= To Json ${resp.content} pretty_print="Hello"
33+
Log ${output}
34+
Should Contain ${output} "key_one": "true"
35+
Should Contain ${output} "key_two": "this is a test string"
36+
Should Not Contain ${output} {u'key_two': u'this is a test string', u'key_one': u'true'}
37+
38+
*** Keywords ***
39+
40+
Setup Response For Json Tests
41+
${resp}= GET On Session ${GLOBAL_SESSION} /anything params=${dict_params}
42+
Set Suite Variable ${resp}

atests/issues/17.robot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*** Settings ***
22
Library Collections
33
Library String
4-
Library ../../src/RequestsLibrary/RequestsKeywords.py
4+
Library RequestsLibrary
55
Library OperatingSystem
66
Suite Teardown Delete All Sessions
77

@@ -11,6 +11,6 @@ ${JSON_DATA} '{"file":{"path":"/logo1.png"},"token":"some-valid-oauth-token"}'
1111
*** Test Cases ***
1212
Delete Request With Data
1313
Create Session httpbin http://httpbin.org
14-
&{headers}= Create Dictionary Content-Type=application/json
14+
${headers}= Create Dictionary Content-Type=application/json
1515
${resp}= Delete Request httpbin /delete data=${JSON_DATA} headers=${headers}
1616
${jsondata}= To Json ${resp.content}

atests/issues/18.robot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*** Settings ***
22
Library Collections
33
Library String
4-
Library ../../src/RequestsLibrary/RequestsKeywords.py
4+
Library RequestsLibrary
55
Library OperatingSystem
66
Suite Teardown Delete All Sessions
77

@@ -11,8 +11,8 @@ ${JSON_DATA} '{"file":{"path":"/logo1.png"},"token":"some-valid-oauth-token"}'
1111
*** Test Cases ***
1212
Encoding Error
1313
Create Session httpbin http://httpbin.org
14-
&{headers}= Create Dictionary Content-Type=application/json
14+
${headers}= Create Dictionary Content-Type=application/json
1515
Set Suite Variable ${data} { "elementToken":"token", "matchCriteria":[{"field":"name","dataType":"string","useOr":"false","fieldValue":"Operation check 07", "closeParen": "false", "openParen": "false", "operator": "equalTo"}], "account": { "annualRevenue": "456666", "name": "Account", "numberOfEmployees": "integer", "billingAddress": { "city": "Miami", "country": "US", "countyOrDistrict": "us or fl", "postalCode": "33131", "stateOrProvince": "florida", "street1": "Trade Center", "street2": "North Main rd" }, "number": "432", "industry": "Bank", "type": "string", "shippingAddress": { "city": "denver", "country": "us", "countyOrDistrict": "us or co", "postalCode": "80202", "stateOrProvince": "colorado", "street1": "Main street", "street2": "101 Avenu"}}}
1616

1717
${resp}= Post Request httpbin /post data=${data} headers=${headers}
18-
Should Be Equal As Strings ${resp.status_code} 200
18+
Should Be Equal As Strings ${resp.status_code} 200

atests/issues/259.robot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*** Settings ***
2-
Library ../../src/RequestsLibrary/RequestsKeywords.py
2+
Library RequestsLibrary
33
Resource ../res_setup.robot
44

55
Suite Setup Setup Flask Http Server
@@ -9,9 +9,9 @@ Suite Teardown Teardown Flask Http Server And Sessions
99
*** Test Cases ***
1010
Post Content application/json With Empty Data Should Have No Body
1111
${content-type}= Create Dictionary content-type application/json
12-
${resp}= Post Request ${GLOBAL_LOCAL_SESSION} /anything data=${EMPTY} headers=${content-type}
12+
${resp}= Post Request ${GLOBAL_SESSION} /anything data=${EMPTY} headers=${content-type}
1313
Should Be Empty ${resp.json()['data']}
1414

1515
Post Content With Empty Data Should Have No Body
16-
${resp}= Post Request ${GLOBAL_LOCAL_SESSION} /anything data=${EMPTY}
16+
${resp}= Post Request ${GLOBAL_SESSION} /anything data=${EMPTY}
1717
Should Be Empty ${resp.json()['data']}

atests/issues/27.robot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*** Settings ***
22
Library Collections
33
Library String
4-
Library ../../src/RequestsLibrary/RequestsKeywords.py
4+
Library RequestsLibrary
55
Library OperatingSystem
66
Suite Teardown Delete All Sessions
77

@@ -11,8 +11,8 @@ Post Request With XML File
1111
Create Session httpbin http://httpbin.org
1212

1313
${file_data}= Get File ${CURDIR}${/}test.xml
14-
&{files}= Create Dictionary xml=${file_data}
15-
&{headers}= Create Dictionary Authorization=testing-token
14+
${files}= Create Dictionary xml=${file_data}
15+
${headers}= Create Dictionary Authorization=testing-token
1616
Log ${headers}
1717
${resp}= Post Request httpbin /post files=${files} headers=${headers}
1818

atests/issues/305.robot

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
*** Settings ***
2-
Library ../../src/RequestsLibrary/RequestsKeywords.py
3-
2+
Library RequestsLibrary
43

54
*** Test Cases ***
65
Test NTLM Session without installed library

atests/res_setup.robot

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
*** Settings ***
22
Library Process
3-
Library ../src/RequestsLibrary/RequestsKeywords.py
3+
Library RequestsLibrary
44

55

66
*** Variables ***
7-
${GLOBAL_LOCAL_SESSION} global_local_session
8-
${HTTP_LOCAL_SERVER} http://localhost:5000
7+
${GLOBAL_SESSION} global_session
8+
${HTTP_LOCAL_SERVER} http://localhost:5000
99

1010

1111
*** Keywords ***
@@ -23,13 +23,14 @@ Setup Flask Http Server
2323
${flask_cmd} = Set Variable If
2424
... '${platform}'=='win32' ${CURDIR}/http_server/run.cmd
2525
... ${CURDIR}/http_server/run.sh
26+
# No way to have the return code or other data on the process since it's in background
2627
Start Process ${flask_cmd} cwd=${CURDIR}/http_server/ alias=flask
27-
Create Session ${GLOBAL_LOCAL_SESSION} ${HTTP_LOCAL_SERVER}
28+
Create Session ${GLOBAL_SESSION} ${HTTP_LOCAL_SERVER}
2829
Wait Until Http Server Is Up And Running
2930

3031
Wait Until Http Server Is Up And Running
3132
Create Session wait-until-up ${HTTP_LOCAL_SERVER} max_retries=10
32-
Get Request wait-until-up /
33+
Get On Session wait-until-up /
3334

3435
Teardown Flask Http Server And Sessions
3536
Delete All Sessions

0 commit comments

Comments
 (0)