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


Python PhoneNumbers.purchase方法代码示例

本文整理汇总了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)
开发者ID:42cc,项目名称:twilio-python,代码行数:31,代码来源:test_available_phonenumber.py

示例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'})
开发者ID:ArenaSource,项目名称:twilio-python,代码行数:13,代码来源:test_phone_numbers.py

示例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"}
            )
开发者ID:RekindleInc,项目名称:twilio-python,代码行数:14,代码来源:test_phone_numbers.py


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