本文整理汇总了Python中twilio.rest.resources.PhoneNumbers.purchase方法的典型用法代码示例。如果您正苦于以下问题:Python PhoneNumbers.purchase方法的具体用法?Python PhoneNumbers.purchase怎么用?Python PhoneNumbers.purchase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twilio.rest.resources.PhoneNumbers
的用法示例。
在下文中一共展示了PhoneNumbers.purchase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PhoneNumbersTest
# 需要导入模块: from twilio.rest.resources import PhoneNumbers [as 别名]
# 或者: from twilio.rest.resources.PhoneNumbers import purchase [as 别名]
class PhoneNumbersTest(unittest.TestCase):
def setUp(self):
self.resource = PhoneNumbers("http://api.twilio.com",
("user", "pass"))
def test_reference(self):
assert_equal(self.resource.available_phone_numbers.phone_numbers,
self.resource)
def test_purchase_status_callback(self):
request = Mock()
response = Mock()
response.status_code = 201
request.return_value = (response, {"sid": ""})
self.resource.request = request
self.resource.purchase(area_code="530", status_callback_url="http://",
status_callback_method="POST")
uri = "http://api.twilio.com/IncomingPhoneNumbers"
data = {
"AreaCode": "530",
"StatusCallback": "http://",
"StatusCallbackMethod": "POST",
}
request.assert_called_with("POST", uri, data=data)
示例2: test_purchase_type
# 需要导入模块: from twilio.rest.resources import PhoneNumbers [as 别名]
# 或者: from twilio.rest.resources.PhoneNumbers import purchase [as 别名]
def test_purchase_type(self):
types = {'local': 'Local', 'mobile': 'Mobile', 'tollfree': 'TollFree'}
for type in ('local', 'mobile', 'tollfree'):
resource = PhoneNumbers(self.uri, self.auth)
resource.request = Mock()
resource.request.return_value = (None, None)
resource.load_instance = Mock()
resource.purchase(type=type, phone_number='888')
resource.request.assert_called_with('POST', self.uri + '/IncomingPhoneNumbers/' + types[type],
data={'PhoneNumber': '888'})
示例3: test_purchase_type
# 需要导入模块: from twilio.rest.resources import PhoneNumbers [as 别名]
# 或者: from twilio.rest.resources.PhoneNumbers import purchase [as 别名]
def test_purchase_type(self):
types = {"local": "Local", "mobile": "Mobile", "tollfree": "TollFree"}
for type in ("local", "mobile", "tollfree"):
resource = PhoneNumbers(self.uri, self.auth)
resource.request = Mock()
resource.request.return_value = (None, None)
resource.load_instance = Mock()
resource.purchase(type=type, phone_number="888")
resource.request.assert_called_with(
"POST", self.uri + "/IncomingPhoneNumbers/" + types[type], data={"PhoneNumber": "888"}
)