本文整理汇总了Python中client_test_lib.Bootstrap.action_failure方法的典型用法代码示例。如果您正苦于以下问题:Python Bootstrap.action_failure方法的具体用法?Python Bootstrap.action_failure怎么用?Python Bootstrap.action_failure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类client_test_lib.Bootstrap
的用法示例。
在下文中一共展示了Bootstrap.action_failure方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_failure
# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import action_failure [as 别名]
def test_failure(self):
bootstrap = Bootstrap(ztps_default_config=True)
config = random_string()
url = config
bootstrap.ztps.set_definition_response(
actions=[{'action' : 'startup_config_action'},
{'action' : 'test_action',
'attributes': {'url' : url}}])
bootstrap.ztps.set_action_response(
'startup_config_action', startup_config_action())
bootstrap.ztps.set_action_response('test_action',
get_action('run_bash_script'))
contents = '''#!/usr/bin/env python
assert False'''
bootstrap.ztps.set_file_response(config, contents)
bootstrap.start_test()
try:
self.failUnless('AssertionError' in bootstrap.output)
self.failUnless(bootstrap.action_failure())
except AssertionError as assertion:
print 'Output: %s' % bootstrap.output
print 'Error: %s' % bootstrap.error
raise_exception(assertion)
finally:
bootstrap.end_test()
示例2: test_failure
# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import action_failure [as 别名]
def test_failure(self):
bootstrap = Bootstrap(ztps_default_config=True)
config = random_string()
url = config
bootstrap.ztps.set_definition_response(
actions=[{'action' : 'test_action',
'attributes': {'url' : url}}])
bootstrap.ztps.set_action_response('test_action',
get_action('run_cli_commands'))
contents = random_string()
bootstrap.ztps.set_file_response(config, contents)
bootstrap.eapi.add_failing_command(contents)
bootstrap.start_test()
try:
self.failUnless(eapi_log()[-1] == contents)
self.failUnless(bootstrap.action_failure())
self.failUnless('Running CLI commands [\'%s\'] failed' %
contents in bootstrap.output)
except AssertionError as assertion:
print 'Output: %s' % bootstrap.output
print 'Error: %s' % bootstrap.error
raise_exception(assertion)
finally:
bootstrap.end_test()
示例3: action_fail_test
# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import action_failure [as 别名]
def action_fail_test(self, action):
bootstrap = Bootstrap()
bootstrap.ztps.set_config_response()
bootstrap.ztps.set_node_check_response()
bootstrap.ztps.set_definition_response(
actions=[{'action' : 'test_action'}])
bootstrap.ztps.set_action_response('test_action', action)
bootstrap.start_test()
try:
self.failUnless(bootstrap.eapi_node_information_collected())
self.failUnless(bootstrap.action_failure())
self.failIf(bootstrap.error)
except AssertionError as assertion:
print 'Output: %s' % bootstrap.output
print 'Error: %s' % bootstrap.error
raise assertion
finally:
bootstrap.end_test()
示例4: test_action_failure
# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import action_failure [as 别名]
def test_action_failure(self):
bootstrap = Bootstrap()
bootstrap.ztps.set_config_response()
bootstrap.ztps.set_node_check_response()
bootstrap.ztps.set_definition_response(
actions=[{'action' : 'test_action'}])
flash_filename = random_string()
bootstrap.ztps.set_action_response(
'test_action',
fail_flash_file_action(bootstrap.flash,
flash_filename))
open(bootstrap.rc_eos, 'w').write(random_string())
open(bootstrap.startup_config, 'w').write(random_string())
open(bootstrap.boot_extensions, 'w').write(random_string())
os.mkdir(bootstrap.boot_extensions_folder)
open('%s/my_extension' %
bootstrap.boot_extensions_folder, 'w').write(random_string())
bootstrap.start_test()
try:
self.failUnless(bootstrap.eapi_node_information_collected())
self.failUnless(bootstrap.action_failure())
self.failIf(bootstrap.error)
self.failIf(os.path.isfile('%s/%s' %
(bootstrap.flash,
flash_filename)))
self.failIf(os.path.isfile(bootstrap.rc_eos))
self.failIf(os.path.isfile(bootstrap.startup_config))
self.failIf(os.path.isfile(bootstrap.boot_extensions))
self.failIf(os.path.isdir(bootstrap.boot_extensions_folder))
except AssertionError as assertion:
print 'Output: %s' % bootstrap.output
print 'Error: %s' % bootstrap.error
raise_exception(assertion)
finally:
bootstrap.end_test()
示例5: test_bad_file_status
# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import action_failure [as 别名]
def test_bad_file_status(self):
bootstrap = Bootstrap(ztps_default_config=True)
config = random_string()
url = 'http://%s/%s' % (bootstrap.server, config)
bootstrap.ztps.set_definition_response(
actions=[{'action' : 'test_action',
'attributes': {'url' : url}}])
bootstrap.ztps.set_action_response('test_action',
get_action('replace_config'))
contents = random_string()
bootstrap.ztps.set_file_response(config, contents,
status=STATUS_NOT_FOUND)
bootstrap.start_test()
try:
self.failUnless(bootstrap.action_failure())
msg = [x for x in bootstrap.output.split('\n') if x][-1]
self.failUnless('return code 2' in msg)
except AssertionError:
raise
finally:
bootstrap.end_test()
示例6: test_action_failure_log
# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import action_failure [as 别名]
def test_action_failure_log(self):
log = '/tmp/ztps-log-%s-debug' % os.getpid()
bootstrap = Bootstrap()
bootstrap.ztps.set_config_response(logging=[
{'destination' : 'file:%s' % log,
'level' : 'DEBUG'},])
bootstrap.ztps.set_node_check_response()
text_onstart = random_string()
text_onsuccess = random_string()
text_onfailure = random_string()
bootstrap.ztps.set_definition_response(
actions=[{'action' : 'test_action',
'onstart' : text_onstart,
'onsuccess' : text_onsuccess,
'onfailure' : text_onfailure},
])
bootstrap.ztps.set_action_response('test_action',
fail_action())
bootstrap.start_test()
try:
self.failUnless(bootstrap.eapi_node_information_collected())
self.failUnless(bootstrap.action_failure())
self.failIf(bootstrap.error)
log = ''.join(file_log(log))
self.failUnless('test_action:%s' % text_onstart in log)
self.failUnless('test_action:%s' % text_onsuccess not in log)
self.failUnless('test_action:%s' % text_onfailure in log)
except AssertionError as assertion:
print 'Output: %s' % bootstrap.output
print 'Error: %s' % bootstrap.error
raise assertion
finally:
bootstrap.end_test()