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


Python resources.PhoneNumbers类代码示例

本文整理汇总了Python中twilio.rest.resources.PhoneNumbers的典型用法代码示例。如果您正苦于以下问题:Python PhoneNumbers类的具体用法?Python PhoneNumbers怎么用?Python PhoneNumbers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: PhoneNumbersTest

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,代码行数:29,代码来源:test_available_phonenumber.py

示例2: test_application_sid

 def test_application_sid(self):
     resource = PhoneNumbers(self.uri, self.auth)
     resource.update_instance = Mock()
     resource.update("SID", application_sid="foo")
     resource.update_instance.assert_called_with(
         "SID", {"voice_application_sid": "foo", "sms_application_sid": "foo"}
     )
开发者ID:RekindleInc,项目名称:twilio-python,代码行数:7,代码来源:test_phone_numbers.py

示例3: test_purchase_type

    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,代码行数:11,代码来源:test_phone_numbers.py

示例4: test_purchase_type

    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,代码行数:12,代码来源:test_phone_numbers.py

示例5: IncomingPhoneNumbersTest

class IncomingPhoneNumbersTest(unittest.TestCase):
    def setUp(self):
        self.resource = PhoneNumbers("http://api.twilio.com", ("user", "pass"))

    def test_mobile(self):
        request = Mock()
        request.return_value = (Mock(), {"incoming_phone_numbers": []})
        self.resource.request = request
        self.resource.list(type="mobile")

        uri = "http://api.twilio.com/IncomingPhoneNumbers/Mobile"
        request.assert_called_with("GET", uri, params={})

    def test_local(self):
        request = Mock()
        request.return_value = (Mock(), {"incoming_phone_numbers": []})
        self.resource.request = request
        self.resource.list(type="local")

        uri = "http://api.twilio.com/IncomingPhoneNumbers/Local"
        request.assert_called_with("GET", uri, params={})

    def test_toll_free(self):
        request = Mock()
        request.return_value = (Mock(), {"incoming_phone_numbers": []})
        self.resource.request = request
        self.resource.list(type="tollfree")

        uri = "http://api.twilio.com/IncomingPhoneNumbers/TollFree"
        request.assert_called_with("GET", uri, params={})
开发者ID:RekindleInc,项目名称:twilio-python,代码行数:30,代码来源:test_phone_numbers.py

示例6: test_transfer

 def test_transfer(self):
     resource = PhoneNumbers(self.uri, self.auth)
     resource.update = Mock()
     resource.transfer("SID", "AC123")
     resource.update.assert_called_with("SID", account_sid="AC123")
开发者ID:AmmoBear,项目名称:twilio-python,代码行数:5,代码来源:test_phone_numbers.py

示例7: test_status_callback_url

 def test_status_callback_url(self):
     resource = PhoneNumbers(self.uri, self.auth)
     resource.update_instance = Mock()
     resource.update("SID", status_callback="foo")
     resource.update_instance.assert_called_with(
             "SID", {"status_callback": "foo"})
开发者ID:AmmoBear,项目名称:twilio-python,代码行数:6,代码来源:test_phone_numbers.py

示例8: test_update_instance_rename_status_callback_url

 def test_update_instance_rename_status_callback_url(self):
     resource = PhoneNumbers(self.uri, self.auth)
     resource.update_instance = Mock()
     resource.update("SID", status_callback_url="http://www.example.com")
     resource.update_instance.assert_called_with("SID", {"status_callback": "http://www.example.com"})
开发者ID:Roguelazer,项目名称:twilio-python,代码行数:5,代码来源:test_phone_numbers.py

示例9: setUp

 def setUp(self):
     self.resource = PhoneNumbers("http://api.twilio.com",
                                  ("user", "pass"))
开发者ID:42cc,项目名称:twilio-python,代码行数:3,代码来源:test_available_phonenumber.py


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