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


Python check.Comparator类代码示例

本文整理汇总了Python中jnpr.jsnapy.check.Comparator的典型用法代码示例。如果您正苦于以下问题:Python Comparator类的具体用法?Python Comparator怎么用?Python Comparator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Comparator类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_contains_ignore_null_fail_1

 def test_contains_ignore_null_fail_1(self, mock_path):
     self.chk = False
     comp = Comparator()
     conf_file = os.path.join(os.path.dirname(__file__),
                              'configs', 'main_contains_ignore-null_fail_1.yml')
     config_file = open(conf_file, 'r')
     mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     main_file = yaml.load(config_file)
     oper = comp.generate_test_files(
         main_file,
         self.hostname,
         self.chk,
         self.diff,
         self.db,
         self.snap_del,
         "snap_contains_pre")
     self.assertEqual(oper.no_passed, 0)
     self.assertEqual(oper.no_failed, 1)
开发者ID:vnitinv,项目名称:jsnapy,代码行数:18,代码来源:test_string_op.py

示例2: test_exists_fail

 def test_exists_fail(self, mock_path, mock_debug, mock_info):
     self.chk = False
     comp = Comparator()
     conf_file = os.path.join(os.path.dirname(__file__),
                              'configs', 'main_exists.yml')
     mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     config_file = open(conf_file, 'r')
     main_file = yaml.load(config_file)
     oper = comp.generate_test_files(
         main_file,
         self.hostname,
         self.chk,
         self.diff,
         self.db,
         self.snap_del,
         "snap_exists_fail_pre")
     self.assertEqual(oper.no_passed, 0)
     self.assertEqual(oper.no_failed, 1)
开发者ID:vnitinv,项目名称:jsnapy,代码行数:18,代码来源:test_str_numeric_op.py

示例3: test_is_equal_success_ignore_null_2

 def test_is_equal_success_ignore_null_2(self, mock_path, mock_debug, mock_info):
     self.chk = False
     comp = Comparator()
     conf_file = os.path.join(os.path.dirname(__file__),
                              'configs', 'main_is-equal_ignore-null_6.yml')
     mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     config_file = open(conf_file, 'r')
     main_file = yaml.load(config_file)
     oper = comp.generate_test_files(
         main_file,
         self.hostname,
         self.chk,
         self.diff,
         self.db,
         self.snap_del,
         "snap_is-equal_pre_special")
     self.assertEqual(oper.no_passed, 0)
     self.assertEqual(oper.no_failed, 1)
开发者ID:vnitinv,项目名称:jsnapy,代码行数:18,代码来源:test_str_numeric_op.py

示例4: test_all_same_ignore_null_3

 def test_all_same_ignore_null_3(self, mock_path, mock_debug, mock_info):
     self.chk = False
     comp = Comparator()
     conf_file = os.path.join(os.path.dirname(__file__),
                              'configs', 'main_all-same-ignore-null_3.yml')
     mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     config_file = open(conf_file, 'r')
     main_file = yaml.load(config_file)
     oper = comp.generate_test_files(
         main_file,
         self.hostname,
         self.chk,
         self.diff,
         self.db,
         self.snap_del,
         "snap_all-same-success_pre")
     self.assertEqual(oper.no_passed, 0) #comparison between None values. All values are None.   
     self.assertEqual(oper.no_failed, 1)
开发者ID:vnitinv,项目名称:jsnapy,代码行数:18,代码来源:test_str_numeric_op.py

示例5: test_xml_comparator

 def test_xml_comparator(self, mock_path):
     self.chk = True
     comp = Comparator()  # created changes in the test file
     conf_file = os.path.join(os.path.dirname(__file__),
                              'configs', 'main_xml_comparator.yml')
     mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     config_file = open(conf_file, 'r')
     main_file = yaml.load(config_file)
     oper = comp.generate_test_files(
         main_file,
         self.hostname,
         self.chk,
         self.diff,
         self.db,
         self.snap_del,
         "pre_xml_compare",
         self.action,
         "post_xml_compare")
     self.assertEqual(oper.no_failed,1)
开发者ID:vnitinv,项目名称:jsnapy,代码行数:19,代码来源:test_operator.py

示例6: test_regex_errors

 def test_regex_errors(self, mock_path):
     with self.assertRaises(IndexError):
         self.chk = True
         comp = Comparator()  # created changes in the test file
         conf_file = os.path.join(os.path.dirname(__file__),
                                  'configs', 'main_regex.yml')
         mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
         config_file = open(conf_file, 'r')
         main_file = yaml.load(config_file)
         oper = comp.generate_test_files(
             main_file,
             self.hostname,
             self.chk,
             self.diff,
             self.db,
             self.snap_del,
             "pre_regex",
             self.action,
             "post_regex_empty")
开发者ID:vnitinv,项目名称:jsnapy,代码行数:19,代码来源:test_operator.py

示例7: test_delta_Index_error

 def test_delta_Index_error(self, mock_path, mock_error):
     with self.assertRaises(Exception):
         self.chk = True
         comp = Comparator()                 #created changes in the test file
         conf_file = os.path.join(os.path.dirname(__file__),
                                  'configs', 'main_test_delta_index_error.yml')
         mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
         config_file = open(conf_file, 'r')
         main_file = yaml.load(config_file)
         oper = comp.generate_test_files(
             main_file,
             self.hostname,
             self.chk,
             self.diff,
             self.db,
             self.snap_del,
             "pre_list_not_more_no_node",
             self.action,
             "post_list_not_more_no_node")
开发者ID:vnitinv,项目名称:jsnapy,代码行数:19,代码来源:test_operator.py

示例8: test_list_not_more_missing_node

 def test_list_not_more_missing_node(self, mock_path):
     self.chk = True
     comp = Comparator()
     conf_file = os.path.join(os.path.dirname(__file__),
                              'configs', 'main_list_not_more_node_missing.yml')
     mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     config_file = open(conf_file, 'r')
     main_file = yaml.load(config_file)
     oper = comp.generate_test_files(
         main_file,
         self.hostname,
         self.chk,
         self.diff,
         self.db,
         self.snap_del,
         "pre_list_not_more_node_missing",
         self.action,
         "post_list_not_more_node_missing")
     self.assertEqual(oper.no_passed, 0)
     self.assertEqual(oper.no_failed, 1)
开发者ID:vnitinv,项目名称:jsnapy,代码行数:20,代码来源:test_operator.py

示例9: test_list_not_less_ignore_null_skip

 def test_list_not_less_ignore_null_skip(self, mock_path):
     self.chk = True
     comp = Comparator()
     conf_file = os.path.join(os.path.dirname(__file__),
                              'configs', 'main_list-not-less_ignore-null_skip.yml')
     mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     config_file = open(conf_file, 'r')
     main_file = yaml.load(config_file)
     oper = comp.generate_test_files(
         main_file,
         self.hostname,
         self.chk,
         self.diff,
         self.db,
         self.snap_del,
         "snap_no-diff_pre",
         self.action,
         "snap_no-diff_post")
     self.assertEqual(oper.no_passed, 0)
     self.assertEqual(oper.no_failed, 1)
开发者ID:vnitinv,项目名称:jsnapy,代码行数:20,代码来源:test_comparison_op.py

示例10: test_list_not_more_ignore_null_fail_1

 def test_list_not_more_ignore_null_fail_1(self, mock_path):
     self.chk = True
     comp = Comparator()
     conf_file = os.path.join(os.path.dirname(__file__),
                              'configs', 'main_list-not-more_ignore-null_fail_1.yml')
     mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     config_file = open(conf_file, 'r')
     main_file = yaml.load(config_file)
     oper = comp.generate_test_files(
         main_file,
         self.hostname,
         self.chk,
         self.diff,
         self.db,
         self.snap_del,
         "snap_no-diff_pre",
         self.action,
         "snap_3")
     self.assertEqual(oper.no_passed, 2)#the name is kinda misleading but in line with the convention    
     self.assertEqual(oper.no_failed, 0)
开发者ID:vnitinv,项目名称:jsnapy,代码行数:20,代码来源:test_comparison_op.py

示例11: test_no_diff_2_pass

 def test_no_diff_2_pass(self, mock_sqlite_path, mock_path):
     self.chk = True
     comp = Comparator()
     conf_file = os.path.join(os.path.dirname(__file__),
                              'configs', 'main_dot-dot.yml')
     mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     mock_sqlite_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     config_file = open(conf_file, 'r')
     main_file = yaml.load(config_file)
     oper = comp.generate_test_files(
         main_file,
         self.hostname,
         self.chk,
         self.diff,
         self.db,
         self.snap_del,
         "snap_no-diff_pre",
         self.action,
         "snap_3")
     self.assertEqual(oper.no_passed, 6)
     self.assertEqual(oper.no_failed, 0)
开发者ID:vnitinv,项目名称:jsnapy,代码行数:21,代码来源:test_comparison_op.py

示例12: test_no_diff_pass

    def test_no_diff_pass(self, sqlite_mock_path, mock_path):
        self.hostname = '10.216.193.114'
        self.chk = True
        self.db['check_from_sqlite'] = True
        comp = Comparator()
        conf_file = os.path.join(os.path.dirname(__file__),
                                 'configs', 'main_no-diff_sql.yml')
        mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
        sqlite_mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')

        config_file = open(conf_file, 'r')
        main_file = yaml.load(config_file)
        oper = comp.generate_test_files(
            main_file,
            self.hostname,
            self.chk,
            self.diff,
            self.db,
            self.snap_del,
            "snap_no-diff_pre",
            self.action,
            "snap_no-diff_post1")
        self.assertEqual(oper.no_passed, 6)
        self.assertEqual(oper.no_failed, 0)
开发者ID:vnitinv,项目名称:jsnapy,代码行数:24,代码来源:test_comparison_op.py

示例13: compare_tests

 def compare_tests(
         self, hostname, config_data, pre_snap=None, post_snap=None, action=None):
     """
     called by check and snapcheck argument, to compare snap files
     calls the function to compare snapshots based on arguments given
     (--check, --snapcheck, --diff)
     :param hostname: device name
     :return: return object of Operator containing test details
     """
     comp = Comparator()
     chk = self.args.check
     diff = self.args.diff
     pre_snap_file = self.args.pre_snapfile if pre_snap is None else pre_snap
     if (chk or diff or action in ["check", "diff"]):
         post_snap_file = self.args.post_snapfile if post_snap is None else post_snap
         test_obj = comp.generate_test_files(
             config_data,
             hostname,
             chk,
             diff,
             self.db,
             self.snap_del,
             pre_snap_file,
             action,
             post_snap_file)
     else:
         test_obj = comp.generate_test_files(
             config_data,
             hostname,
             chk,
             diff,
             self.db,
             self.snap_del,
             pre_snap_file,
             action)
     return test_obj
开发者ID:vnitinv,项目名称:jsnapy,代码行数:36,代码来源:jsnapy.py

示例14: check_arguments

    def check_arguments(self):
        """
        checks combination of arguments given from command line and display help if correct
        set of combination is not given.
        :return: print message in command line, regarding correct usage of JSNAPy
        """
        ## only four test operation is permitted, if given anything apart from this, then it should print error message
        if (self.args.snap is False and self.args.snapcheck is False and self.args.check is False and self.args.diff is False and self.args.version is False):
            self.logger.error(colorama.Fore.RED +
                              "Arguments not given correctly, Please refer help message", extra=self.log_detail)
            self.parser.print_help()
            sys.exit(1)

        if(((self.args.snap is True and (self.args.pre_snapfile is None or self.args.file is None)) or
            (self.args.snapcheck is True and self.args.file is None) or
            (self.args.check is True and self.args.file is None)) and 
            (self.args.testfiles is None or self.args.hostname is None)
           ):
            self.logger.error(colorama.Fore.RED +
                              "Arguments not given correctly, Please refer help message", extra=self.log_detail)
            self.parser.print_help()
            sys.exit(1)
        if self.args.diff is True:
            if (self.args.pre_snapfile is not None and os.path.isfile(self.args.pre_snapfile)) and (
                    self.args.post_snapfile is not None and os.path.isfile(self.args.post_snapfile)):
                comp = Comparator()
                comp.compare_diff(
                    self.args.pre_snapfile,
                    self.args.post_snapfile,
                    None)
                sys.exit(1)
            else:
                if (self.args.file is None) and (
                    self.args.testfiles is None or self.args.hostname is None):
                    self.parser.print_help()
                    sys.exit(1)
开发者ID:vnitinv,项目名称:jsnapy,代码行数:36,代码来源:jsnapy.py


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