mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
add parse_response_object
This commit is contained in:
@@ -20,3 +20,10 @@ def load_testcases(testcase_file_path):
|
||||
else:
|
||||
# '' or other suffix
|
||||
raise ParamsError("Bad testcase file name!")
|
||||
|
||||
def parse_response_object(resp_obj):
|
||||
return {
|
||||
'status_code': resp_obj.status_code,
|
||||
'headers': resp_obj.headers,
|
||||
'content': resp_obj.content
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import os
|
||||
import unittest
|
||||
import requests
|
||||
from ate import utils
|
||||
from ate import exception
|
||||
from .base import ApiServerUnittest
|
||||
|
||||
class TestUtils(unittest.TestCase):
|
||||
class TestUtils(ApiServerUnittest):
|
||||
|
||||
def test_load_testcases_bad_filepath(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'test/data/demo')
|
||||
@@ -29,3 +30,11 @@ class TestUtils(unittest.TestCase):
|
||||
self.assertIn('response', testcases[0])
|
||||
self.assertIn('url', testcases[0]['request'])
|
||||
self.assertIn('method', testcases[0]['request'])
|
||||
|
||||
def test_parse_response_object(self):
|
||||
url = "http://127.0.0.1:5000/api/users"
|
||||
resp_obj = requests.get(url)
|
||||
parse_result = utils.parse_response_object(resp_obj)
|
||||
self.assertIn('status_code', parse_result)
|
||||
self.assertIn('headers', parse_result)
|
||||
self.assertIn('content', parse_result)
|
||||
|
||||
Reference in New Issue
Block a user