def test_hash_merge_mode_cli_overrides_ini_defaults(
         self, quiet_logger, tmp_path_factory, cli, ini, mode):
     config_file = create_temp_yaml_file(
         tmp_path_factory, """
     [defaults]
     hashes = {}
     """.format(ini))
     mc = MergerConfig(quiet_logger,
                       SimpleNamespace(config=config_file, hashes=cli))
     assert mc.hash_merge_mode(NodeCoords(None, None, None)) == mode
 def test_hash_merge_mode_ini(self, quiet_logger, tmp_path_factory, setting,
                              mode):
     config_file = create_temp_yaml_file(
         tmp_path_factory, """
     [defaults]
     hashes = {}
     """.format(setting))
     mc = MergerConfig(quiet_logger,
                       SimpleNamespace(config=config_file, hashes=None))
     assert mc.hash_merge_mode(NodeCoords(None, None, None)) == mode
    def test_hash_merge_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]
        hashes = {}
        [rules]
        /hash = {}
        """.format(ini_default, ini_rule))
        lhs_yaml_file = create_temp_yaml_file(
            tmp_path_factory, """---
        hash:
          lhs_exclusive: lhs value 1
          merge_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 = MergerConfig(quiet_logger,
                          SimpleNamespace(config=config_file, hashes=cli))
        mc.prepare(lhs_data)

        node = lhs_data["hash"]
        parent = lhs_data
        parentref = "hash"

        assert mc.hash_merge_mode(NodeCoords(node, parent, parentref)) == mode
 def test_hash_merge_mode_cli(self, quiet_logger, setting, mode):
     mc = MergerConfig(quiet_logger, SimpleNamespace(hashes=setting))
     assert mc.hash_merge_mode(NodeCoords(None, None, None)) == mode
 def test_hash_merge_mode_default(self, quiet_logger):
     mc = MergerConfig(quiet_logger, SimpleNamespace(hashes=None))
     assert mc.hash_merge_mode(NodeCoords(None, None,
                                          None)) == HashMergeOpts.DEEP