Giter Site home page Giter Site logo

Comments (2)

zhenzhen1022 avatar zhenzhen1022 commented on May 20, 2024

@debugtalk can you hava a look at this question,thx

from postman2case.

zhenzhen1022 avatar zhenzhen1022 commented on May 20, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.