Python Rest API Test Drive
I need to develop a test case to test the rest of the services, and the only resource provided to me by my client is the WADL file, and with that I need to come up with a test case for the rest of the clients. Wrote using requests and pytest python modules. however not sure if it covers all scripts for this WADl..help, very valuable for clearing up the gaps in the test case if any
WADL: -
resources base="http://mygame.herokuapp.com/rest/">
<resource path="nextgame">
<method id="getNextGame" name="GET">
<response>
<representation mediaType="text/plain"/>
</response>
</method>
</resource>
<resource path="lastGame">
<method id="getLastGame" name="GET">
<response>
<representation mediaType="text/plain"/>
</response>
</method>
</resource>
<resource path="recentGame">
<method id="getRecentGame" name="GET">
<response>
<representation mediaType="text/plain"/>
</response>
</method>
</resource>
</resources>
</application>
My Python test case:
import pytest
import requests
@pytest.mark.parametrize("input,expected", [
("http://mygame.herokuapp.com/rest/lastgame", 'XYZ'),
("http://mygame.herokuapp.com/rest/nextgame", 'ABC'),
("http://mygame.herokuapp.com/rest/recentmovie", 'DEF')
])
def test_eval(input, expected):
r = requests.get(input)
assert r.text == expected
assert r.status_code==200
assert r.headers['Content-Type']=='text/plain'
+3
source to share
No one has answered this question yet
Check out similar questions: