Comments (2)
@debugtalk can you hava a look at this question,thx
from postman2case.
The testcases are genereated by postman2case, and I find the solution by update core.py in postman2case.
location: postman2case/core.py:76
solution: add "body = json.loads(body, encoding='utf-8')" and change "request["data"] = body" to "request["json"] = body" . now, the question is solved.
def parse_each_item(self, item):
""" parse each item in postman to testcase in httprunner
"""
api = {}
api["name"] = item["name"]
api["validate"] = [{"check": "status_code", "comparator": "eq", "expect": 200},{"eq": ["content.ResponseStatus.Ack", "Success"]}]
api["variables"] = []
request = {}
request["method"] = item["request"]["method"]
url = self.parse_url(item["request"]["url"])
if request["method"] == "GET":
request["url"] = url.split("?")[0]
request["headers"] = self.parse_header(item["request"]["header"])
body = {}
if "query" in item["request"]["url"].keys():
for query in item["request"]["url"]["query"]:
api["variables"].append({query["key"]: parse_value_from_type(query["value"])})
body[query["key"]] = "$"+query["key"]
request["params"] = body
else:
request["url"] = url
request["headers"] = self.parse_header(item["request"]["header"])
body = {}
if item["request"]["body"] != {}:
mode = item["request"]["body"]["mode"]
if isinstance(item["request"]["body"][mode], list):
for param in item["request"]["body"][mode]:
if param["type"] == "text":
api["variables"].append({param["key"]: parse_value_from_type(param["value"])})
else:
api["variables"].append({param["key"]: parse_value_from_type(param["src"])})
body[param["key"]] = "$"+param["key"]
elif isinstance(item["request"]["body"][mode], str):
body = item["request"]["body"][mode]
body = json.loads(body, encoding='utf-8')
request["json"] = body
api["request"] = request
return api
from postman2case.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postman2case.