Ejemplo n.º 1
0
    def test_set_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]
        sets = {}
        [rules]
        /hash/merge_targets/subset = {}
        """.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
            subset:
              ? one
              ? two
        """)
        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, sets=cli))
        mc.prepare(lhs_data)

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

        assert mc.set_merge_mode(NodeCoords(node, parent, parentref)) == mode
Ejemplo n.º 2
0
 def test_set_merge_mode_ini(self, quiet_logger, tmp_path_factory, setting,
                             mode):
     config_file = create_temp_yaml_file(
         tmp_path_factory, """
     [defaults]
     sets = {}
     """.format(setting))
     mc = MergerConfig(quiet_logger,
                       SimpleNamespace(config=config_file, sets=None))
     assert mc.set_merge_mode(NodeCoords(None, None, None)) == mode
Ejemplo n.º 3
0
 def test_set_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]
     sets = {}
     """.format(ini))
     mc = MergerConfig(quiet_logger,
                       SimpleNamespace(config=config_file, sets=cli))
     assert mc.set_merge_mode(NodeCoords(None, None, None)) == mode
Ejemplo n.º 4
0
 def test_set_merge_mode_cli(self, quiet_logger, setting, mode):
     mc = MergerConfig(quiet_logger, SimpleNamespace(sets=setting))
     assert mc.set_merge_mode(NodeCoords(None, None, None)) == mode
Ejemplo n.º 5
0
 def test_set_merge_mode_default(self, quiet_logger):
     mc = MergerConfig(quiet_logger, SimpleNamespace(sets=None))
     assert mc.set_merge_mode(NodeCoords(None, None,
                                         None)) == SetMergeOpts.UNIQUE