本文整理匯總了Python中edx_rest_api_client.client.EdxRestApiClient.user_agent方法的典型用法代碼示例。如果您正苦於以下問題:Python EdxRestApiClient.user_agent方法的具體用法?Python EdxRestApiClient.user_agent怎麽用?Python EdxRestApiClient.user_agent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edx_rest_api_client.client.EdxRestApiClient
的用法示例。
在下文中一共展示了EdxRestApiClient.user_agent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_user_agent
# 需要導入模塊: from edx_rest_api_client.client import EdxRestApiClient [as 別名]
# 或者: from edx_rest_api_client.client.EdxRestApiClient import user_agent [as 別名]
def test_user_agent(self):
"""Make sure our custom User-Agent is getting built correctly."""
with mock.patch('socket.gethostbyname', return_value='test_hostname'):
default_user_agent = user_agent()
self.assertIn('python-requests', default_user_agent)
self.assertIn('edx-rest-api-client/{}'.format(__version__), default_user_agent)
self.assertIn('test_hostname', default_user_agent)
with mock.patch('socket.gethostbyname') as mock_gethostbyname:
mock_gethostbyname.side_effect = ValueError()
default_user_agent = user_agent()
self.assertIn('unknown_client_name', default_user_agent)
with mock.patch.dict(os.environ, {'EDX_REST_API_CLIENT_NAME': "awesome_app"}):
uagent = user_agent()
self.assertIn('awesome_app', uagent)
self.assertEqual(user_agent(), EdxRestApiClient.user_agent())