Example #1
0
    def test_disassociate_phone_numbers_instance(self, request):
        resp = Mock()
        resp.status_code = 204
        request.return_value = resp

        phone_numbers = PhoneNumbers(BASE_URI, AUTH)
        result = phone_numbers.delete('PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')

        assert_true(result)

        request.assert_called_with(
            "DELETE",
            "{0}/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".format(
                BASE_URI),
            auth=AUTH,
            use_json_extension=False)
Example #2
0
    def test_associate_phone_numbers_instance(self, request):
        resp = create_mock_json(
            'tests/resources/trunking/phone_numbers_instance.json')
        resp.status_code = 201
        request.return_value = resp

        phone_numbers = PhoneNumbers(BASE_URI, AUTH)
        result = phone_numbers.create('PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')

        assert_equal(result.sid, 'PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
        assert_equal(result.account_sid, 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
        assert_equal(result.trunk_sid, "TK11111111111111111111111111111111")
        assert_equal(result.friendly_name, "Name")
        assert_equal(result.phone_number, "+14158675309")
        assert_equal(result.api_version, "2010-04-01")
        assert_equal(result.voice_caller_id_lookup, False)
        assert_equal(result.voice_fallback_method, "POST")
        assert_equal(result.status_callback_method, "POST")
        assert_equal(result.sms_url,
                     "https://demo.twilio.com/welcome/sms/reply/")
        assert_equal(result.sms_method, "POST")
        assert_equal(result.sms_fallback_method, "POST")
        assert_equal(result.address_requirements, "none")
        assert_equal(result.beta, False)
        assert_equal(
            result.url,
            "{0}/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".format(
                BASE_URI))
        assert_equal(
            result.links['phone_number'],
            "{0}/{1}".format(PHONE_NUMBERS_BASE_URI,
                             "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))

        data_dict = dict()
        data_dict['PhoneNumberSid'] = 'PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        request.assert_called_with(
            "POST",
            "{0}/PhoneNumbers".format(BASE_URI),
            auth=AUTH,
            use_json_extension=False,
            data=data_dict,
        )
Example #3
0
    def test_get_phone_numbers_lists(self, request):
        resp = create_mock_json(
            'tests/resources/trunking/phone_numbers_list.json')
        resp.status_code = 200
        request.return_value = resp

        phone_numbers = PhoneNumbers(BASE_URI, AUTH)
        result = phone_numbers.list()

        assert_equal(len(result), 1)
        assert_equal(result[0].sid, 'PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
        assert_equal(result[0].account_sid,
                     'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
        assert_equal(result[0].trunk_sid, "TK11111111111111111111111111111111")
        assert_equal(result[0].friendly_name, "Name")
        assert_equal(result[0].phone_number, "+14158675309")
        assert_equal(result[0].api_version, "2010-04-01")
        assert_equal(result[0].voice_caller_id_lookup, False)
        assert_equal(result[0].voice_fallback_method, "POST")
        assert_equal(result[0].status_callback_method, "POST")
        assert_equal(result[0].sms_url,
                     "https://demo.twilio.com/welcome/sms/reply/")
        assert_equal(result[0].sms_method, "POST")
        assert_equal(result[0].sms_fallback_method, "POST")
        assert_equal(result[0].address_requirements, "none")
        assert_equal(result[0].beta, False)
        assert_equal(
            result[0].url,
            "{0}/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".format(
                BASE_URI))
        assert_equal(
            result[0].links['phone_number'],
            "{0}/{1}".format(PHONE_NUMBERS_BASE_URI,
                             "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
        request.assert_called_with(
            "GET",
            "{0}/PhoneNumbers".format(BASE_URI),
            auth=AUTH,
            params={},
            use_json_extension=False,
        )