Python Rest API测试用例
我需要开发测试rest服务的测试用例,我的客户机提供给我的唯一资源是WADL文件,在这个帮助下,我需要拿出rest客户机测试用例。使用python的请求和pytest模块编写。但是,不确定它是否涵盖了这个WADl的所有场景。非常感谢帮助找出测试用例中的差距(如果有的话) WADL:-Python Rest API测试用例,python,rest,python-requests,pytest,wadl,Python,Rest,Python Requests,Pytest,Wadl,我需要开发测试rest服务的测试用例,我的客户机提供给我的唯一资源是WADL文件,在这个帮助下,我需要拿出rest客户机测试用例。使用python的请求和pytest模块编写。但是,不确定它是否涵盖了这个WADl的所有场景。非常感谢帮助找出测试用例中的差距(如果有的话) WADL:- resources base="http://mygame.herokuapp.com/rest/"> <resource path="nextgame"> <method id="
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>
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'