Skip to content

Commit 12d2c7c

Browse files
committed
update requestlibrary case
1 parent 2667bb5 commit 12d2c7c

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

RequestsDemo/request.txt

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ Library XML
66
*** Test Cases ***
77
case1
88
Create Session api http://localhost:8000
9+
${addr} Get Request api users/1
10+
Comment Should Be Equal As Strings ${addr.status_code} 200
11+
log ${addr.content}
12+
${responsedata} to json ${addr.content}
13+
${body} Get Dictionary Keys ${responsedata}
14+
${body} Get Dictionary Items ${responsedata}
15+
${body} Get Dictionary Values ${responsedata}
16+
${str} Get From Dictionary ${responsedata} 1
917
${addr} Get Request api users/5
1018
Comment Should Be Equal As Strings ${addr.status_code} 200
1119
log ${addr.content}
@@ -17,11 +25,40 @@ case1
1725

1826
case2
1927
Create Session api http://localhost:8000
20-
${addr} Get Request api qitao
28+
${addr} Get Request api hello/qitao
2129
Comment Should Be Equal As Strings ${addr.status_code} 200
2230
log ${addr.content}
23-
${responsedata} to json ${addr.content}
31+
log ${addr}
32+
${responsedata} To Json ${addr.content}
2433
${body} Get Dictionary Keys ${responsedata}
2534
${body} Get Dictionary Items ${responsedata}
2635
${body} Get Dictionary Values ${responsedata}
2736
${str} Get From Dictionary ${responsedata} hello
37+
#xml方式
38+
${dict} Create Dictionary accept=application/xml
39+
${addr} get Request api hello/qitao ${dict}
40+
Comment Should Be Equal As Strings ${addr.status_code} 200
41+
log ${addr.content}
42+
log ${addr}
43+
${responsedata} Set Variable ${addr.content}
44+
${body} Get Element Text ${responsedata} hello
45+
${hello} Get Element ${responsedata} hello
46+
log ${hello.text}
47+
${responsedata} Add Element ${responsedata} <new id="3">test</new>
48+
${new} Get Element Attribute ${responsedata} id new
49+
log ${new}
50+
${a} Element To String ${responsedata}
51+
52+
case3
53+
#用户密码
54+
${auth} Create List ok python
55+
Create Session api http://localhost:8000 \ \ ${auth}
56+
${addr} get Request api 401
57+
Comment Should Be Equal As Strings ${addr.status_code} 200
58+
log ${addr.content}
59+
log ${addr}
60+
${responsedata} to json ${addr.content}
61+
${body} Get Dictionary Keys ${responsedata}
62+
${body} Get Dictionary Items ${responsedata}
63+
${body} Get Dictionary Values ${responsedata}
64+
${str} Get From Dictionary ${responsedata} pass

demo-website/flaskdemo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def get(self, entry):
4848
return {'hello': entry}
4949

5050

51-
api.add_resource(Hello, '/<string:entry>')
51+
api.add_resource(Hello, '/hello/<string:entry>')
5252

5353

5454

@@ -85,16 +85,16 @@ def decorated(*args, **kwargs):
8585
return decorated
8686

8787

88-
@app.before_request
88+
"""@app.before_request
8989
def before_request():
9090
if request.path != '/':
9191
if not request.headers['content-type'].find('application/json'):
92-
return 'Unsupported Media Type', 415
92+
return 'Unsupported Media Type', 415"""
9393

9494
@app.route('/401/')
9595
@auth.login_required
9696
def unauthorized():
97-
return make_response(jsonify({'error': 'Unauthorized access'}), 403)
97+
return make_response(jsonify({'pass': 'Authorized access'}), 200)
9898
#return 'Unauthorized access', 401
9999

100100
@app.errorhandler(404)

0 commit comments

Comments
 (0)