用于wiremock的python http客户端

sky-wiremock的Python项目详细描述


空中模拟

https://img.shields.io/pypi/v/sky_wiremock.svghttps://img.shields.io/travis/grubert65/sky_wiremock.svgDocumentation Status

用于wiremock的python http客户端

功能

用法:

from sky_wiremock.sky_wiremock import Wiremock

# get a client object
w = Wiremock("localhost", 8080)


# get the list of all mappings defined
mappings = w.mappings()

# get a mapping by its id
mapping = w.mapping_by_id(id)

# get a mapping by its request path and method
mapping = w.mapping_by_url_and_method(url, method)

# add a single mapping and get back its id
id = w.add_mapping({
    "request": {
        "method": "GET",
        "url": "/some/thing"
    },
    "response": {
        "status": 200,
        "body": "Hello world!",
        "headers": {
            "Content-Type": "text/plain"
        }
    }
})

# populate wiremock with a list of mappings and
# get their ids
ids = w.populate([{
    "request": {
        "method": "GET",
        "url": "/some/thing"
    },
    "response": {
        "status": 200,
        "body": "Hello world!",
        "headers": {
            "Content-Type": "text/plain"
        }
    }
},{
    "request": {
        "method": "GET",
        "url": "/some/thing/else"
    },
        "response": {
        "status": 200,
        "body": "Hello world again!",
        "headers": {
            "Content-Type": "text/plain"
        }
    }
}])

# delete a mapping by its id
# returns the deleted mapping id or -1 in
# case of errors
id = w.delete_mapping(id)

# add a fixed delay to a mapping
delayed_id = w.fixed_delay(url, method, 10000)

# add a global fixed delay
ret = w.global_fixed_delay(300)

# add a random delay to a mapping dictionary
delayed_id = w.random_delay(
    filter={
        "method": "GET",
        "url": "/some/thing/to/delay"
    },
    delayDistribution={
        "type": "lognormal",
        "median": 80,
        "sigma": 0.4
    })

# add a global random delay
ret = w.global_random_delay({
    "type": "lognormal",
    "median": 90,
    "sigma": 0.1
})

# add a chunked dribble delay to a mapping
delayed_id = w.chunked_dribble_delay(mapping, {
    "numberOfChunks": 5,
    "totalDuration": 1000
})

# resets a list of mappings deleting all delays attached to them
# returns the list of mapping ids actually reset
ids_up = w.up([{
    "method": "GET",
    "url": "/some/thing/to/delete"
}])

学分

这个包是用Cookiecutteraudreyr/cookiecutter-pypackage项目模板创建的。

历史记录

0.1.0(2019-02-12)

  • pypi上的第一个版本。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaSpringMVC控制器测试打印结果JSON字符串   若catch语句返回,那个么为什么它最终会阻塞呢?   java Grails中servletContext在哪里可用?   java Jhipster:如何为现有项目启用多种语言   java异常评估SpringEL表达式:“#fields.hasErrors('something')”   java如何验证SeleniumWebDriver中的文本颜色?   java在绘图时使用JPanel坐标   java如何初始化spring启动到project?   java如何通过JDBC的PreparedStatement将UUID数组插入HyperSQL数据库   java修改JVM以跨线程序列化文件访问   Javascript到Java正则表达式   使用Java运行时调用aspell程序时出现字符集问题。getRuntime()。执行官   执行RDP时的java Sukuli按钮识别   java如何使用okhttp更改connect请求的标头   java无法创建Maven Eclipse项目