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


Python tools.create_mock_json函数代码示例

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


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

示例1: test_login_error_handler

    def test_login_error_handler(self):
        mock_response = create_mock_json('tests/resources/login_success.json')
        assert self.login._error_handler(mock_response.json()) is None

        mock_response = create_mock_json('tests/resources/login_fail.json')
        with self.assertRaises(LoginError):
            self.login._error_handler(mock_response.json())
开发者ID:LiamPa,项目名称:betfairlightweight,代码行数:7,代码来源:test_login.py

示例2: test_base_endpoint_error_handler

    def test_base_endpoint_error_handler(self):
        mock_response = create_mock_json('tests/resources/base_endpoint_success.json')
        assert self.base_endpoint._error_handler(mock_response.json()) is None

        mock_response = create_mock_json('tests/resources/base_endpoint_fail.json')
        with self.assertRaises(APIError):
            self.base_endpoint._error_handler(mock_response.json())
开发者ID:LiamPa,项目名称:betfairlightweight,代码行数:7,代码来源:test_baseendpoint.py

示例3: test_keep_alive_error_handler

    def test_keep_alive_error_handler(self):
        mock_response = create_mock_json('tests/resources/keep_alive_success.json')
        assert self.keep_alive._error_handler(mock_response.json()) is None

        mock_response = create_mock_json('tests/resources/keep_alive_fail.json')
        with self.assertRaises(KeepAliveError):
            self.keep_alive._error_handler(mock_response.json())
开发者ID:LiamPa,项目名称:betfairlightweight,代码行数:7,代码来源:test_keepalive.py

示例4: test_call

    def test_call(self, mock_response):
        mock = create_mock_json('tests/resources/keep_alive_success.json')
        mock_response.return_value = mock
        response = self.keep_alive()

        assert response == mock.json()
        assert self.keep_alive.client.session_token == mock.json().get('token')
开发者ID:LiamPa,项目名称:betfairlightweight,代码行数:7,代码来源:test_keepalive.py

示例5: test_create_origination_urls_instance

    def test_create_origination_urls_instance(self, request):
        resp = create_mock_json('tests/resources/trunking/origination_urls_instance.json')
        resp.status_code = 201
        request.return_value = resp

        origination_urls = OriginationUrls(BASE_URI, AUTH)
        result = origination_urls.create('Name', 'sip:169.10.1.35')

        assert_equal(result.sid, "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
        assert_equal(result.account_sid, "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
        assert_equal(result.trunk_sid, "TK11111111111111111111111111111111")
        assert_equal(result.friendly_name, "Name")
        assert_equal(result.sip_url, "sip:169.10.1.35")
        assert_equal(result.weight, 10)
        assert_equal(result.priority, 20)
        assert_true(result.enabled)
        assert_equal(result.url, "{0}/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".format(BASE_URI))

        data_dict = dict()
        data_dict['FriendlyName'] = 'Name'
        data_dict['SipUrl'] = 'sip:169.10.1.35'
        data_dict['Priority'] = 10
        data_dict['Weight'] = 10
        data_dict['Enabled'] = 'true'

        request.assert_called_with(
            "POST",
            "{0}/OriginationUrls".format(BASE_URI),
            auth=AUTH,
            use_json_extension=False,
            data=data_dict,
        )
开发者ID:Adomako-Bismark,项目名称:twilio-python,代码行数:32,代码来源:test_origination_urls.py

示例6: test_members

 def test_members(self, mock_request):
     resp = create_mock_json("tests/resources/members_list.json")
     mock_request.return_value = resp
     self.client.members("QU123").list()
     mock_request.assert_called_with("GET", ANY, params=ANY, auth=AUTH,
                                     timeout=sentinel.timeout,
                                     use_json_extension=True)
开发者ID:lyft,项目名称:twilio-python,代码行数:7,代码来源:test_client.py

示例7: test_place_orders

    def test_place_orders(self):
        mock_response = create_mock_json('tests/resources/place_orders.json')
        place_orders = mock_response.json().get('result')
        resource = resources.PlaceOrders(date_time_sent=self.DATE_TIME_SENT,
                                        **place_orders)
        assert resource._datetime_sent == self.DATE_TIME_SENT
        assert resource.market_id == place_orders['marketId']
        assert resource.status == place_orders['status']
        assert resource.customer_ref == place_orders.get('customerRef')
        assert resource.error_code == place_orders.get('errorCode')
        assert len(resource.place_instruction_reports) == len(place_orders.get('instructionReports'))

        for order in place_orders.get('instructionReports'):
            assert resource.place_instruction_reports[0].size_matched == order['sizeMatched']
            assert resource.place_instruction_reports[0].status == order['status']
            assert resource.place_instruction_reports[0].bet_id == order['betId']
            assert resource.place_instruction_reports[0].average_price_matched == order['averagePriceMatched']
            assert resource.place_instruction_reports[0].placed_date == datetime.datetime.strptime(
                        order['placedDate'], "%Y-%m-%dT%H:%M:%S.%fZ")
            assert resource.place_instruction_reports[0].error_code == order.get('errorCode')

            assert resource.place_instruction_reports[0].instruction.selection_id == order['instruction']['selectionId']
            assert resource.place_instruction_reports[0].instruction.side == order['instruction']['side']
            assert resource.place_instruction_reports[0].instruction.order_type == order['instruction']['orderType']
            assert resource.place_instruction_reports[0].instruction.handicap == order['instruction']['handicap']

            assert resource.place_instruction_reports[0].instruction.order.persistence_type == order['instruction']['limitOrder']['persistenceType']
            assert resource.place_instruction_reports[0].instruction.order.price == order['instruction']['limitOrder']['price']
            assert resource.place_instruction_reports[0].instruction.order.size == order['instruction']['limitOrder']['size']
开发者ID:LiamPa,项目名称:betfairlightweight,代码行数:29,代码来源:test_bettingresources.py

示例8: test_call

    def test_call(self, mock_response):
        mock = create_mock_json('tests/resources/logout_success.json')
        mock_response.return_value = mock
        response = self.logout()

        assert response == mock.json()
        assert self.logout.client.session_token is None
开发者ID:LiamPa,项目名称:betfairlightweight,代码行数:7,代码来源:test_logout.py

示例9: test_call

    def test_call(self, mock_response):
        mock = create_mock_json('tests/resources/login_success.json')
        mock_response.return_value = mock
        response = self.login()

        assert response == mock.json()
        assert self.login.client.session_token == mock.json().get('sessionToken')
开发者ID:LiamPa,项目名称:betfairlightweight,代码行数:7,代码来源:test_login.py

示例10: test_events

def test_events(mock):
    client = TwilioMonitorClient("ACCOUNT_SID", "AUTH_TOKEN")
    resp = create_mock_json("tests/resources/monitor/events_instance.json")
    mock.return_value = resp
    client.events.get("AEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    uri = "https://monitor.twilio.com/v1/Events/AEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    mock.assert_called_with("GET", uri, auth=("ACCOUNT_SID", "AUTH_TOKEN"), use_json_extension=False)
开发者ID:Adomako-Bismark,项目名称:twilio-python,代码行数:7,代码来源:test_client.py

示例11: test_create_call_feedback_one_request

    def test_create_call_feedback_one_request(self, request):
        resp = create_mock_json('tests/resources/call_feedback.json')
        resp.status_code = 201
        request.return_value = resp

        base_uri = 'https://api.twilio.com/2010-04-01/Accounts/AC123'
        account_sid = 'AC123'
        auth = (account_sid, "token")

        calls = Calls(base_uri, auth)
        uri = "%s/Calls/CA123/Feedback" % base_uri
        feedback = calls.feedback(
            'CA123',
            quality_score=5,
            issue=['imperfect-audio', 'post-dial-delay']
        )

        exp_data = {
            'QualityScore': 5,
            'Issue': ['imperfect-audio', 'post-dial-delay'],
        }

        assert_equal(['imperfect-audio', 'post-dial-delay'], feedback.issues)
        request.assert_called_with(
            "POST", uri,
            data=exp_data, auth=auth,
            use_json_extension=True,
        )
开发者ID:Adomako-Bismark,项目名称:twilio-python,代码行数:28,代码来源:test_call_feedback.py

示例12: test_members

 def test_members(self, mock):
     resp = create_mock_json("tests/resources/members_list.json")
     mock.return_value = resp
     self.client.members("QU123").list()
     uri = "https://api.twilio.com/2010-04-01/Accounts/ACCOUNT_SID/Queues/QU123/Members"
     mock.assert_called_with("GET", uri, params={}, auth=AUTH,
                             use_json_extension=True)
开发者ID:AgrAlert,项目名称:AgrAlert_Backend,代码行数:7,代码来源:test_client.py

示例13: test_get_origination_urls_lists

    def test_get_origination_urls_lists(self, request):
        resp = create_mock_json('tests/resources/trunking/origination_urls_list.json')
        resp.status_code = 200
        request.return_value = resp

        origination_urls = OriginationUrls(BASE_URI, AUTH)
        result = origination_urls.list()

        assert_equal(len(result), 1)
        assert_equal(result[0].sid, 'OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
        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].sip_url, "sip:169.10.1.35")
        assert_equal(result[0].weight, 10)
        assert_equal(result[0].priority, 20)
        assert_true(result[0].enabled)
        assert_equal(result[0].url, "{0}/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".format(BASE_URI))

        request.assert_called_with(
            "GET",
            "{0}/OriginationUrls".format(BASE_URI),
            auth=AUTH,
            params={},
            use_json_extension=False,
        )
开发者ID:Adomako-Bismark,项目名称:twilio-python,代码行数:26,代码来源:test_origination_urls.py

示例14: test_create_call_feedback

    def test_create_call_feedback(self, request):
        resp = create_mock_json('tests/resources/call_feedback.json')
        resp.status_code = 201
        request.return_value = resp

        mock = Mock()
        mock.uri = '/base'
        mock.auth = AUTH
        call = Call(mock, 'CA123')
        call.load_subresources()
        feedback = call.feedback.create(
            quality_score=5,
            issues=['imperfect-audio', 'post-dial-delay'],
        )

        exp_data = {
            'QualityScore': 5,
            'Issues': ['imperfect-audio', 'post-dial-delay'],
        }
        assert_equal(5, feedback.quality_score, 5)
        assert_equal(['imperfect-audio', 'post-dial-delay'], feedback.issues)
        request.assert_called_with(
            "POST", "/base/CA123/Feedback",
            data=exp_data, auth=AUTH,
            timeout=ANY, use_json_extension=True,
        )
开发者ID:Adomako-Bismark,项目名称:twilio-python,代码行数:26,代码来源:test_call_feedback.py

示例15: test_number_country

    def test_number_country(self, request):
        resp = create_mock_json('tests/resources/pricing/phone_number_country_instance.json')
        resp.status_code = 200
        request.return_value = resp

        countries = PhoneNumberCountries(BASE_URI + "/PhoneNumbers", AUTH)
        country = countries.get('EE')

        assert_equal(country.country, "Estonia")
        assert_equal(
            country.phone_number_prices,
            [
                {
                    'type': 'mobile',
                    'base_price': 3.00,
                    'current_price': 3.00,
                },
                {
                    'type': 'national',
                    'base_price': 1.00,
                    'current_price': 1.00,
                }
            ],
        )

        request.assert_called_with(
            "GET",
            "{0}/PhoneNumbers/Countries/EE".format(BASE_URI),
            auth=AUTH,
            use_json_extension=False,
        )
开发者ID:Adomako-Bismark,项目名称:twilio-python,代码行数:31,代码来源:test_numbers.py


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