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


Python Bootstrap.action_failure方法代码示例

本文整理汇总了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()
开发者ID:arista-eosplus,项目名称:ztpserver,代码行数:30,代码来源:test_run_bash_script.py

示例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()
开发者ID:arista-eosplus,项目名称:ztpserver,代码行数:29,代码来源:test_run_cli_commands.py

示例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()
开发者ID:IntelligentVisibility,项目名称:ztpserver,代码行数:21,代码来源:test_bootstrap.py

示例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()
开发者ID:arista-eosplus,项目名称:ztpserver,代码行数:42,代码来源:test_bootstrap_cleanup.py

示例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()
开发者ID:IntelligentVisibility,项目名称:ztpserver,代码行数:24,代码来源:test_replace_config.py

示例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()
开发者ID:IntelligentVisibility,项目名称:ztpserver,代码行数:38,代码来源:test_bootstrap.py


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