本文整理汇总了Python中three.Three.post方法的典型用法代码示例。如果您正苦于以下问题:Python Three.post方法的具体用法?Python Three.post怎么用?Python Three.post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类three.Three
的用法示例。
在下文中一共展示了Three.post方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_a_default_post
# 需要导入模块: from three import Three [as 别名]
# 或者: from three.Three import post [as 别名]
def test_a_default_post(self):
t = Three('api.city.gov', api_key='my_api_key')
t.post('123', name='Zach Williams', address='85 2nd Street')
params = {'first_name': 'Zach', 'last_name': 'Williams',
'service_code': '123', 'address_string': '85 2nd Street',
'api_key': 'my_api_key'}
expected = 'https://api.city.gov/requests.json'
t.session.post.assert_called_with(expected, data=params, files=None)
示例2: test_a_default_post
# 需要导入模块: from three import Three [as 别名]
# 或者: from three.Three import post [as 别名]
def test_a_default_post(self):
t = Three("api.city.gov", api_key="my_api_key")
t.post("123", name="Zach Williams", address="85 2nd Street")
params = {
"first_name": "Zach",
"last_name": "Williams",
"service_code": "123",
"address_string": "85 2nd Street",
"api_key": "my_api_key",
}
expected = "https://api.city.gov/requests.json"
req.post.assert_called_with(expected, data=params)
示例3: test_post_request_with_api_key_argument
# 需要导入模块: from three import Three [as 别名]
# 或者: from three.Three import post [as 别名]
def test_post_request_with_api_key_argument(self):
t = Three('http://seeclicktest.com/open311/v2')
t.post('1627', name='Zach Williams', address='120 Spring St',
description='Just a test post.', phone='555-5555',
api_key='my_api_key')
params = {
'first_name': 'Zach', 'last_name': 'Williams',
'description': 'Just a test post.', 'service_code': '1627',
'address_string': '120 Spring St', 'phone': '555-5555',
'api_key': 'my_api_key'
}
expected = 'http://seeclicktest.com/open311/v2/requests.json'
t.session.post.assert_called_with(expected, data=params, files=None)
示例4: test_post_request_with_api_key_argument
# 需要导入模块: from three import Three [as 别名]
# 或者: from three.Three import post [as 别名]
def test_post_request_with_api_key_argument(self):
t = Three("http://seeclicktest.com/open311/v2")
t.post(
"1627",
name="Zach Williams",
address="120 Spring St",
description="Just a test post.",
phone="555-5555",
api_key="my_api_key",
)
params = {
"first_name": "Zach",
"last_name": "Williams",
"description": "Just a test post.",
"service_code": "1627",
"address_string": "120 Spring St",
"phone": "555-5555",
"api_key": "my_api_key",
}
expected = "http://seeclicktest.com/open311/v2/requests.json"
req.post.assert_called_with(expected, data=params)
示例5: test_a_default_post
# 需要导入模块: from three import Three [as 别名]
# 或者: from three.Three import post [as 别名]
def test_a_default_post(self):
responses.add(responses.POST, 'https://api.city.gov/requests.json',
body="""[
{
"service_request_id":293944,
"service_notice":"The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code",
"account_id":null
}
]""",
status=201,
content_type='application/json')
t = Three('api.city.gov', api_key='my_api_key')
resp = t.post('123', name='Zach Williams', address='85 2nd Street')
params = {'first_name': 'Zach', 'last_name': 'Williams',
'service_code': '123', 'address_string': '85 2nd Street',
'api_key': 'my_api_key'}
assert resp.status_code == 201