def test_aoh_merge_mode_ini(self, quiet_logger, tmp_path_factory, setting,
                             mode):
     config_file = create_temp_yaml_file(
         tmp_path_factory, """
     [defaults]
     aoh = {}
     """.format(setting))
     mc = MergerConfig(quiet_logger,
                       SimpleNamespace(config=config_file, aoh=None))
     assert mc.aoh_merge_mode(NodeCoords(None, None, None)) == mode
 def test_aoh_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]
     aoh = {}
     """.format(ini))
     mc = MergerConfig(quiet_logger,
                       SimpleNamespace(config=config_file, aoh=cli))
     assert mc.aoh_merge_mode(NodeCoords(None, None, None)) == mode
    def test_aoh_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]
        aoh = {}
        [rules]
        /array_of_hashes = {}
        """.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, aoh=cli))
        mc.prepare(lhs_data)

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

        assert mc.aoh_merge_mode(NodeCoords(node, parent, parentref)) == mode
 def test_aoh_merge_mode_cli(self, quiet_logger, setting, mode):
     mc = MergerConfig(quiet_logger, SimpleNamespace(aoh=setting))
     assert mc.aoh_merge_mode(NodeCoords(None, None, None)) == mode
 def test_aoh_merge_mode_default(self, quiet_logger):
     mc = MergerConfig(quiet_logger, SimpleNamespace(aoh=None))
     assert mc.aoh_merge_mode(NodeCoords(None, None,
                                         None)) == AoHMergeOpts.ALL