def test_array_diff_mode_cli_overrides_ini_defaults( self, quiet_logger, tmp_path_factory, cli, ini, mode): config_file = create_temp_yaml_file( tmp_path_factory, """ [defaults] arrays = {} """.format(ini)) mc = DifferConfig(quiet_logger, SimpleNamespace(config=config_file, arrays=cli)) assert mc.array_diff_mode(NodeCoords(None, None, None)) == mode
def test_array_diff_mode_ini(self, quiet_logger, tmp_path_factory, setting, mode): config_file = create_temp_yaml_file( tmp_path_factory, """ [defaults] arrays = {} """.format(setting)) mc = DifferConfig(quiet_logger, SimpleNamespace(config=config_file, arrays=None)) assert mc.array_diff_mode(NodeCoords(None, None, None)) == mode
def test_array_diff_mode_ini_rule_overrides_cli(self, quiet_logger, tmp_path_factory, cli, ini_default, ini_rule, mode): config_file = create_temp_yaml_file( tmp_path_factory, """ [defaults] arrays = {} [rules] /hash/diff_targets/subarray = {} """.format(ini_default, ini_rule)) lhs_yaml_file = create_temp_yaml_file( tmp_path_factory, """--- hash: lhs_exclusive: lhs value 1 diff_targets: subkey: lhs value 2 subarray: - one - two array_of_hashes: - name: LHS Record 1 id: 1 prop: LHS value AoH 1 - name: LHS Record 2 id: 2 prop: LHS value AoH 2 """) lhs_yaml = get_yaml_editor() (lhs_data, lhs_loaded) = get_yaml_data(lhs_yaml, quiet_logger, lhs_yaml_file) mc = DifferConfig(quiet_logger, SimpleNamespace(config=config_file, arrays=cli)) mc.prepare(lhs_data) node = lhs_data["hash"]["diff_targets"]["subarray"] parent = lhs_data["hash"]["diff_targets"] parentref = "subarray" assert mc.array_diff_mode(NodeCoords(node, parent, parentref)) == mode
def test_array_diff_mode_cli(self, quiet_logger, setting, mode): mc = DifferConfig(quiet_logger, SimpleNamespace(arrays=setting)) assert mc.array_diff_mode(NodeCoords(None, None, None)) == mode
def test_array_diff_mode_default(self, quiet_logger): mc = DifferConfig(quiet_logger, SimpleNamespace(arrays=None)) assert mc.array_diff_mode(NodeCoords(None, None, None)) == ArrayDiffOpts.POSITION