本文整理汇总了Python中jnpr.jsnapy.check.Comparator.generate_test_files方法的典型用法代码示例。如果您正苦于以下问题:Python Comparator.generate_test_files方法的具体用法?Python Comparator.generate_test_files怎么用?Python Comparator.generate_test_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jnpr.jsnapy.check.Comparator
的用法示例。
在下文中一共展示了Comparator.generate_test_files方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compare_tests
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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
示例2: test_contains_ignore_null_fail_1
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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)
示例3: test_exists_fail
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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)
示例4: test_is_equal_success_ignore_null_2
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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)
示例5: test_all_same_ignore_null_3
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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)
示例6: test_xml_comparator
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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)
示例7: test_regex_errors
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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")
示例8: test_delta_Index_error
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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")
示例9: test_list_not_more_missing_node
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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)
示例10: test_list_not_less_ignore_null_skip
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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)
示例11: test_list_not_more_ignore_null_fail_1
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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)
示例12: test_no_diff_2_pass
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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)
示例13: test_no_diff_pass
# 需要导入模块: from jnpr.jsnapy.check import Comparator [as 别名]
# 或者: from jnpr.jsnapy.check.Comparator import generate_test_files [as 别名]
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)