本文整理汇总了Python中utils.flare.Flare._ask_for_email方法的典型用法代码示例。如果您正苦于以下问题:Python Flare._ask_for_email方法的具体用法?Python Flare._ask_for_email怎么用?Python Flare._ask_for_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.flare.Flare
的用法示例。
在下文中一共展示了Flare._ask_for_email方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_endpoint
# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import _ask_for_email [as 别名]
def test_endpoint(self, mock_config, mock_temp, mock_stfrtime):
f = Flare()
f._ask_for_email = lambda: None
try:
f.upload(confirmation=False)
raise Exception('Should fail before')
except Exception, e:
self.assertEqual(str(e), "Your request is incorrect: Invalid inputs: 'API key unknown'")
示例2: test_endpoint
# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import _ask_for_email [as 别名]
def test_endpoint(self, mock_config, mock_temp, mock_stfrtime):
f = Flare()
f._ask_for_email = lambda: None
f._open_tarfile()
f._tar.close()
with self.assertRaises(Exception) as cm:
f.upload()
self.assertEqual(str(cm.exception), "Your request is incorrect: Invalid inputs: 'API key unknown'")
示例3: test_endpoint
# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import _ask_for_email [as 别名]
def test_endpoint(self, mock_config, mock_temp, mock_stfrtime):
if os.environ['FLARE_BROKEN']:
raise unittest.case.SkipTest('Flare broken, acknowledged')
f = Flare()
f._ask_for_email = lambda: None
f._open_tarfile()
f._tar.close()
with self.assertRaises(Exception) as cm:
f.upload()
self.assertEqual(str(cm.exception), "Your request is incorrect: Invalid inputs: 'API key unknown'")
示例4: test_upload_no_case
# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import _ask_for_email [as 别名]
def test_upload_no_case(self, mock_config, mock_tempdir, mock_stfrtime, mock_version, mock_requests):
f = Flare()
f._ask_for_email = lambda: '[email protected]'
assert not mock_requests.called
f.upload(confirmation=False)
assert mock_requests.called
args, kwargs = mock_requests.call_args_list[0]
self.assertEqual(
args,
('https://6-6-6-flare.agent.datadoghq.com/support/flare?api_key=APIKEY',)
)
self.assertEqual(
kwargs['files']['flare_file'].name,
os.path.join(get_mocked_temp(), "datadog-agent-1.tar.bz2")
)
self.assertEqual(kwargs['data']['case_id'], None)
self.assertEqual(kwargs['data']['email'], '[email protected]')
assert kwargs['data']['hostname']
示例5: test_upload_with_case_proxy
# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import _ask_for_email [as 别名]
def test_upload_with_case_proxy(self, mock_config, mock_tempdir, mock_stfrtime, mock_version, mock_requests):
f = Flare(case_id=1337)
f._ask_for_email = lambda: '[email protected]'
assert not mock_requests.called
f.upload()
assert mock_requests.called
args, kwargs = mock_requests.call_args_list[0]
self.assertEqual(
args,
('https://6-6-6-flare.agent.datadoghq.com/support/flare/1337?api_key=APIKEY',)
)
self.assertEqual(
kwargs['files']['flare_file'].name,
os.path.join(get_mocked_temp(), "datadog-agent-1.tar.bz2")
)
self.assertEqual(kwargs['data']['case_id'], 1337)
self.assertEqual(kwargs['data']['email'], '[email protected]')
assert kwargs['data']['hostname']
assert kwargs['proxies']['https'] == 'http://proxy_user:[email protected]:3128'
assert not kwargs['verify']
示例6: test_upload_with_case
# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import _ask_for_email [as 别名]
def test_upload_with_case(self, mock_config, mock_tempdir, mock_stfrtime,
mock_version, mock_requests, mock_os_remove):
f = Flare(case_id=1337)
f._ask_for_email = lambda: '[email protected]'
f._open_tarfile()
f._tar.close()
assert not mock_requests.called
f.upload()
assert mock_requests.called
args, kwargs = mock_requests.call_args_list[0]
self.assertEqual(
args,
('https://6-6-6-flare.agent.datadoghq.com/support/flare/1337?api_key=APIKEY',)
)
self.assertEqual(
kwargs['files']['flare_file'].name,
os.path.join(get_mocked_temp(), "datadog-agent-1.tar.bz2")
)
self.assertEqual(kwargs['data']['case_id'], 1337)
self.assertEqual(kwargs['data']['email'], '[email protected]')
assert kwargs['data']['hostname']