小编Aks*_*ure的帖子

REST-Assured - 用于获取值列表的JsonPath

我正在使用REST-Assured来测试一些RESTful Web服务.这是我的JSON:

{
    "status":true,
    "responseData":{
        "orderLevelReasons":[
            {
                "reasons":[
                    {
                        "reasonId":"129cfea8-b022-4dc8-9811-222a324f46aa",
                        "reasonName":"COD Amount Mismatch"
                    },
                    {
                        "reasonId":"a881fd5c-626e-438c-8026-646aa2a19098",
                        "reasonName":"Gave wrong information"
                    },
                    {
                        "reasonId":"543d438a-88cc-487c-86e4-19eecefa9ca7",
                        "reasonName":"Late delivery"
                    },
                    {
                        "reasonId":"080cd7c1-7a37-48ad-9090-57286d93ea41",
                        "reasonName":"Parcel not received"
                    },
                    {
                        "reasonId":"5ca3d9b4-0fa2-49da-a534-a6f2e7eccc07",
                        "reasonName":"Staff did not inform about the parcel arrival"
                    }
                ],
                "issueName":"ISSUE TYPE 1",
                "issueId":"0c2c37a6-62b6-4c28-ab6c-566487d045bd",
                "hint":""
            },
            {
                "reasons":[
                    {
                        "reasonId":"129cfea8-b022-4dc8-9811-222a324f46aa",
                        "reasonName":"COD Amount Mismatch"
                    },
                    {
                        "reasonId":"14975b5d-23fb-4735-8082-2e02d6335788",
                        "reasonName":"Data issue"
                    },
                    {
                        "reasonId":"7e6e8446-3774-4589-9171-8e7ab0a7f73b",
                        "reasonName":"Delivery BOY did not inform before delivering"
                    },
                    {
                        "reasonId":"543d438a-88cc-487c-86e4-19eecefa9ca7",
                        "reasonName":"Late delivery"
                    },
                    {
                        "reasonId":"080cd7c1-7a37-48ad-9090-57286d93ea41",
                        "reasonName":"Parcel …
Run Code Online (Sandbox Code Playgroud)

java jsonpath rest-assured rest-assured-jsonpath

7
推荐指数
1
解决办法
2295
查看次数

isEqual 与 isMatch - isMatch 是否忽略嵌套数组元素的顺序?

我使用lodash来比较以下两个对象:

obj1 = {
    "_id": "57767",
    "Re": {
        "PropertyTypes": [
            {
                "AllocationID": 13870,
                "Percentage": null,
                "Type": "Hotels",
                "Value": null
            },
            {
                "AllocationID": 13867,
                "Percentage": null,
                "Type": "Industrial",
                "Value": null
            }
        ]
    }
}

obj2 = {
    "_id": "57767",
    "Re": {
        "PropertyTypes": [
            {
                "AllocationID": 13867,
                "Percentage": null,
                "Type": "Industrial",
                "Value": null
            },
            {
                "AllocationID": 13870,
                "Percentage": null,
                "Type": "Hotels",
                "Value": null
            }
        ]
    }
}
Run Code Online (Sandbox Code Playgroud)

我发现使用isEqual(obj1, obj2),比较失败,使用isMatch(obj1, obj2),则效果很好。

我想知道 和 是否isEqualisMatch …

node.js lodash

3
推荐指数
1
解决办法
4650
查看次数

从Python在Google Sheet中附加一个列表

我有一个Python列表,我只想在Google Sheet的第一列中逐行编写(追加).我已经完成了所有初始身份验证部分,这里是代码:

credentials = GoogleCredentials.get_application_default()
service = build('sheets', 'v4', credentials=credentials)
Run Code Online (Sandbox Code Playgroud)

关于如何以一种简单的方式做到这一点,我没有任何线索.

python google-sheets-api

2
推荐指数
2
解决办法
5065
查看次数

如何以编程方式调用 Locust 测试?

在我的本地主机 (127.0.0.1:8089) 上尝试使用 Locust,但它给出了 400 bad request 错误:

import requests

response = requests.post('http://127.0.0.1:8089/swarm', params={"locust_count":10, "hatch_rate":5})
print response.text
Run Code Online (Sandbox Code Playgroud)

回复:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not understand.</p>
Run Code Online (Sandbox Code Playgroud)

我通过浏览器浏览验证了http://127.0.0.1:8089/确实已启动。代码可以在这篇文章locustfile.py中找到。

python python-2.7 locust

1
推荐指数
1
解决办法
3832
查看次数

response.status_code 为 200,但 response.content 为空

我正在使用 Locust 对一些 API 进行负载测试,下面是 locust 文件 (locustfile.py) 的样子:

class MyTests(TaskSet):

def on_start(self):
    print("Starting tests")

def get_something(self):
    with self.client.get("some_baseuri" + "some_basepath", catch_response=True) as response:
        print("Response code: {}".format(response.status_code))
        print("Response body: {}".format(response.content))

@task(1)
def my_task(self):
    self.get_something()


class WebsiteUser(HttpLocust):
    task_set = MyTests
Run Code Online (Sandbox Code Playgroud)

这是我触发测试的方式:

locust -f locustfile.py --no-web --clients=1 --hatch-rate=10 --host=http://127.0.0.1 --num-request=2 --print-stats --only-summary
Run Code Online (Sandbox Code Playgroud)

问题是,在日志中,response.status_code打印为 200,但response.content恰好是空的。当我使用 Postman 访问相同的 API 时,我在响应中看到了符合预期的正确响应正文。这看起来像是一个奇怪的问题,它阻止我调用另一个依赖于该get_something()方法的 API,因为另一个 API 从get_something()方法中获取一些数据作为输入。

python locust

1
推荐指数
1
解决办法
6983
查看次数