当前位置: 首页>>代码示例>>Python>>正文


Python HttpSession.post方法代码示例

本文整理汇总了Python中locust.clients.HttpSession.post方法的典型用法代码示例。如果您正苦于以下问题:Python HttpSession.post方法的具体用法?Python HttpSession.post怎么用?Python HttpSession.post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在locust.clients.HttpSession的用法示例。


在下文中一共展示了HttpSession.post方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_purchase

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import post [as 别名]
    def create_purchase(self):
        session = HttpSession(self.base_url)
        # self.client.post('/api/v0.9/reservation/', reservation_body)
        reservation_response = session.post("/api/v0.9/reservation/", data=reservation_body)

        if reservation_response.status_code != 201:
            return

        if reservation_response.status_code == 409:
            raise StopLocust("No available tickets.")

        checkout_response = session.post("/api/v0.9/reservation/_checkout", data=checkout_body)

        if checkout_response.status_code != 200:
            return

        purchase = checkout_response.json()["purchase"]
        completion_response = session.post(
            "/api/v0.9/purchases/_complete",
            json.dumps(
                dict(
                    purchase_id=purchase["purchase_id"],
                    hash=purchase["completion_params"]["hash"],
                    processor=purchase["completion_params"]["processor"],
                    payment_ref=purchase["completion_params"]["order_ref"],
                )
            ),
        )
开发者ID:hooplab,项目名称:docker-locust,代码行数:30,代码来源:ticket_release.py

示例2: create_purchase

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import post [as 别名]
    def create_purchase(self):
        session = HttpSession(self.base_url)
        # self.client.post('/api/v0.9/reservation/', reservation_body)
        reservation_response = session.post('/api/v0.9/reservation/', data=reservation_body)

        if reservation_response.status_code != 201:
            return

        checkout_response = session.post('/api/v0.9/reservation/_checkout', data=checkout_body)
开发者ID:hooplab,项目名称:docker-locust,代码行数:11,代码来源:initialize_only.py

示例3: test_post_redirect

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import post [as 别名]
 def test_post_redirect(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     url = "/redirect"
     r = s.post(url)
     self.assertEqual(200, r.status_code)
     post_stats = global_stats.get(url, method="POST")
     get_stats = global_stats.get(url, method="GET")
     self.assertEqual(1, post_stats.num_requests)
     self.assertEqual(0, get_stats.num_requests)
开发者ID:Broadroad,项目名称:locust,代码行数:11,代码来源:test_client.py

示例4: test_post_redirect

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import post [as 别名]
 def test_post_redirect(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     url = "/redirect"
     r = s.post(url)
     assert 200 == r.status_code
     post_stats = global_stats.get(url, method="POST")
     get_stats = global_stats.get(url, method="GET")
     assert 1 == post_stats.num_requests
     assert 0 == get_stats.num_requests
开发者ID:sanga,项目名称:locust,代码行数:11,代码来源:test_client.py

示例5: create_purchase

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import post [as 别名]
    def create_purchase(self):
        session = HttpSession(self.base_url)
        # self.client.post('/api/v0.9/reservation/', reservation_body)
        reservation_response = session.post('/api/v0.9/reservation/', data=reservation_body)

        if reservation_response.status_code != 201:
            return

        checkout_response = session.post('/api/v0.9/reservation/_checkout', data=checkout_body)

        if checkout_response.status_code != 200:
            return

        purchase = checkout_response.json()['purchase']
        completion_response = session.post('/api/v0.9/purchases/_complete', json.dumps(dict(
            purchase_id=purchase['purchase_id'],
            hash=purchase['completion_params']['hash'],
            processor=purchase['completion_params']['processor'],
            payment_ref=purchase['completion_params']['order_ref']
        )))
开发者ID:hooplab,项目名称:docker-locust,代码行数:22,代码来源:complete_purchase.py

示例6: post

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import post [as 别名]
 def post(self):
   session = HttpSession(self.base_url)
   reservation_response = session.post('/prod/insert-product', data=body)
开发者ID:hooplab,项目名称:docker-locust,代码行数:5,代码来源:insert_product.py

示例7: test_cookie

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import post [as 别名]
 def test_cookie(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     r = s.post("/set_cookie?name=testcookie&value=1337")
     self.assertEqual(200, r.status_code)
     r = s.get("/get_cookie?name=testcookie")
     self.assertEqual('1337', r.content.decode())
开发者ID:alexandrul,项目名称:locust,代码行数:8,代码来源:test_client.py

示例8: create_purchase

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import post [as 别名]
 def create_purchase(self):
     session = HttpSession(self.base_url)
     reservation_response = session.post('/api/v0.9/reservation/', data=reservation_body)
开发者ID:hooplab,项目名称:docker-locust,代码行数:5,代码来源:reserve_only.py


注:本文中的locust.clients.HttpSession.post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。