svanoort / pyresttest

Python Rest Testing
Apache License 2.0
1.15k stars 326 forks source link

Add PATCH method to pycurl request #129

Closed lerrua closed 8 years ago

lerrua commented 8 years ago

Hi @svanoort

Thanks again for the great job with pyresttest and sorry for my poor english. Anyway, this Pull Requests can solve #117 issue, now PATCH is really implement.

Please, check this example:

- test:
  - name: "Update an user from Contribution Details as admin"
  - url: "/contribution_details?id=eq.1"
  - headers: {'Content-Type': 'application/json'}
  - method: "PATCH"
  - body: '{"user_id": 2}'
  - expected_status: [204]

It's ours public API specs (you can check here https://github.com/catarse/catarse-api-specs) and running tests i've got this following error

test/contribution_details.yml...
{"message":"Failed to parse JSON payload. not enough input"}
[('transfer-encoding', 'chunked'), ('date', 'Tue, 15 Dec 2015 21:13:46 GMT'), ('server', 'postgrest/0.2.12.0'), ('content-type', 'application/json')]
ERROR:Test Failed: Update an user from Contribution Details as admin URL=http://localhost:8888/contribution_details?id=eq.1 Group=Default HTTP Status Code: 400
ERROR:Test Failure, failure type: Invalid HTTP Response Code, Reason: Invalid HTTP response code: response code 400 not in expected codes [[204]]
Test Group Default FAILED: 2/3 Tests Passed!

With this PR now this example works fine

test/contribution_details.yml...
Test Group Default SUCCEEDED: 3/3 Tests Passed!

Hope you like it :beers:

svanoort-jenkins commented 8 years ago

Can one of the admins verify this patch?

svanoort commented 8 years ago

@svanoort-jenkins jenkins test

svanoort commented 8 years ago

:beers: indeed, thank you!

I added back in part of the testing that wasn't working earlier for PATCH (I assumed it was server-specific, looks like not). Also, added changelog notes for this.

Much appreciated!