本文整理汇总了Python中tests.tools.create_mock_json函数的典型用法代码示例。如果您正苦于以下问题:Python create_mock_json函数的具体用法?Python create_mock_json怎么用?Python create_mock_json使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_mock_json函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_market_book
def test_market_book(self):
mock_response = create_mock_json('tests/resources/list_market_book.json')
market_books = mock_response.json().get('result')
for market_book in market_books:
resource = resources.MarketBook(date_time_sent=self.DATE_TIME_SENT,
**market_book)
assert resource._datetime_sent == self.DATE_TIME_SENT
assert resource.market_id == market_book['marketId']
assert resource.bet_delay == market_book['betDelay']
assert resource.bsp_reconciled == market_book['bspReconciled']
assert resource.complete == market_book['complete']
assert resource.cross_matching == market_book['crossMatching']
assert resource.inplay == market_book['inplay']
assert resource.is_market_data_delayed == market_book['isMarketDataDelayed']
assert resource.last_match_time == datetime.datetime.strptime(
market_book['lastMatchTime'], "%Y-%m-%dT%H:%M:%S.%fZ")
assert resource.number_of_active_runners == market_book['numberOfActiveRunners']
assert resource.number_of_runners == market_book['numberOfRunners']
assert resource.number_of_winners == market_book['numberOfWinners']
assert resource.runners_voidable == market_book['runnersVoidable']
assert resource.status == market_book['status']
assert resource.total_available == market_book['totalAvailable']
assert resource.total_matched == market_book['totalMatched']
assert resource.version == market_book['version']
assert len(resource.runners) == len(market_book['runners'])
for runner in market_book['runners']:
pass
开发者ID:LiamPa,项目名称:betfairlightweight,代码行数:30,代码来源:test_bettingresources.py
示例17: test_triggers_create
def test_triggers_create(request):
resp = create_mock_json("tests/resources/usage_triggers_instance.json")
resp.status_code = 201
request.return_value = resp
usage.triggers.create(
friendly_name="foo",
usage_category="sms",
trigger_by="count",
recurring="price",
trigger_value="10.00",
callback_url="http://www.example.com",
callback_method="POST"
)
uri = "%s/Usage/Triggers" % BASE_URI
request.assert_called_with("POST", uri, data={
"FriendlyName": "foo",
"UsageCategory": "sms",
"TriggerBy": "count",
"Recurring": "price",
"TriggerValue": "10.00",
"CallbackUrl": "http://www.example.com",
"CallbackMethod": "POST"
}, auth=AUTH, use_json_extension=True)
开发者ID:Adomako-Bismark,项目名称:twilio-python,代码行数:25,代码来源:test_usage.py
示例18: test_workflows
def test_workflows(self, request):
resp = create_mock_json("tests/resources/task_router/workflows_list.json")
request.return_value = resp
workflows = self.task_router_client.workflows("WS123")
workflows = workflows.list()
assert_true(workflows[0].sid is not None)
uri = "https://taskrouter.twilio.com/v1/Workspaces/WS123/Workflows"
request.assert_called_with("GET", uri, headers=ANY, params={}, auth=AUTH)
开发者ID:AgrAlert,项目名称:AgrAlert_Backend,代码行数:8,代码来源:test_client.py
示例19: test_get
def test_get(self, mock):
resp = create_mock_json("tests/resources/ip_messaging/message_instance.json")
mock.return_value = resp
uri = "%s/Messages/%s" % (BASE_URI, MESSAGE_SID)
list_resource.get(MESSAGE_SID)
mock.assert_called_with("GET", uri, auth=AUTH, use_json_extension=False)
开发者ID:evandesantola,项目名称:WhatsUpDocEvangelized,代码行数:8,代码来源:test_messages.py
示例20: test_list_keys
def test_list_keys(mock):
resp = create_mock_json("tests/resources/keys_list.json")
mock.return_value = resp
url = BASE_URL + "/Keys"
list_resource.list()
mock.assert_called_with("GET", url, params={}, auth=AUTH, use_json_extension=True)
开发者ID:Adomako-Bismark,项目名称:twilio-python,代码行数:8,代码来源:test_keys.py
注:本文中的tests.tools.create_mock_json函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论