Esempio n. 1
0
def test_empty_string_leads_to_empty_file_during_merge():
    # When the original structure contains a leaf,
    structure = {"a": {"b": "0"}}
    # and the merged structure overrides it with an empty content
    extra_files = {"a": {"b": ""}}
    structure = helpers.merge(structure, extra_files)
    # then the resulting content should exist and be empty
    assert structure["a"]["b"] == ""
Esempio n. 2
0
def test_empty_string_leads_to_empty_file_during_merge():
    # When the original structure contains a leaf,
    structure = {"a": {"b": "0"}}
    # and the merged structure overrides it with an empty content
    extra_files = {"a": {"b": ""}}
    structure = helpers.merge(structure, extra_files)
    # then the resulting content should exist and be empty
    assert structure["a"]["b"] == ""
Esempio n. 3
0
def test_merge_rules_just_in_merged():
    # When an update rule does not exist in the original structure,
    structure = {"a": {"b": "0"}}
    # but exists in the merged,
    extra_files = {"a": {"b": (None, helpers.NO_CREATE)}}
    structure = helpers.merge(structure, extra_files)
    # then just the rule should be updated
    # and the content should be kept identical
    assert structure["a"]["b"] == ("0", helpers.NO_CREATE)
Esempio n. 4
0
def test_merge_rules_just_in_merged():
    # When an update rule does not exist in the original structure,
    structure = {"a": {"b": "0"}}
    # but exists in the merged,
    extra_files = {"a": {"b": (None, helpers.NO_CREATE)}}
    structure = helpers.merge(structure, extra_files)
    # then just the rule should be updated
    # and the content should be kept identical
    assert structure["a"]["b"] == ("0", helpers.NO_CREATE)
Esempio n. 5
0
    def add_files(struct, opts):
        struct = helpers.ensure(struct, "proj/tests/extra.file", "content")
        struct = helpers.merge(
            struct, {"proj": {
                "tests": {
                    "another.file": "content"
                }
            }})

        return struct, opts
Esempio n. 6
0
def test_merge_basics():
    # Given an existing structure,
    structure = {"a": {"b": {"c": "1", "d": "2"}}}
    # when it is merged to another structure with some common folder
    extra_files = {"a": {"b": {"c": "0"}, "e": "2"}, "f": {"g": {"h": "0"}}}
    structure = helpers.merge(structure, extra_files)
    # then the result, should contain both files from the original and the
    # merged structure,
    assert structure["a"]["b"]["d"] == "2"
    assert structure["f"]["g"]["h"] == "0"
    assert structure["a"]["e"] == "2"
    # the common leaves should be overridden and a tuple (content, rule)
    assert structure["a"]["b"]["c"] == "0"
Esempio n. 7
0
    def add_files(struct, opts):
        print("inside opts", opts)
        nov, ncr = helpers.NO_OVERWRITE, helpers.NO_CREATE
        struct = helpers.ensure(struct, "proj/tests/file0", "new")
        struct = helpers.ensure(struct, "proj/tests/file1", "new", nov)
        struct = helpers.ensure(struct, "proj/tests/file2", "new", ncr)
        struct = helpers.merge(struct, {
            "proj": {"tests": {"file3": ("new", nov),
                               "file4": ("new", ncr),
                               "file5": ("new", None),
                               "file6": "new"}}
        })

        return struct, opts
Esempio n. 8
0
def test_merge_basics():
    # Given an existing structure,
    structure = {"a": {"b": {"c": "1",
                             "d": "2"}}}
    # when it is merged to another structure with some common folder
    extra_files = {"a": {"b": {"c": "0"},
                         "e": "2"},
                   "f": {"g": {"h": "0"}}}
    structure = helpers.merge(structure, extra_files)
    # then the result, should contain both files from the original and the
    # merged structure,
    assert structure["a"]["b"]["d"] == "2"
    assert structure["f"]["g"]["h"] == "0"
    assert structure["a"]["e"] == "2"
    # the common leaves should be overridden and a tuple (content, rule)
    assert structure["a"]["b"]["c"] == "0"
Esempio n. 9
0
    def add_files(struct, opts):
        nov, ncr = helpers.NO_OVERWRITE, helpers.NO_CREATE
        struct = helpers.ensure(struct, "proj/tests/file0", "new")
        struct = helpers.ensure(struct, "proj/tests/file1", "new", nov)
        struct = helpers.ensure(struct, "proj/tests/file2", "new", ncr)
        struct = helpers.merge(
            struct, {
                "proj": {
                    "tests": {
                        "file3": ("new", nov),
                        "file4": ("new", ncr),
                        "file5": ("new", None),
                        "file6": "new"
                    }
                }
            })

        return struct, opts
Esempio n. 10
0
    def add_files(struct, opts):
        struct = helpers.ensure(struct, "proj/tests/extra.file", "content")
        struct = helpers.merge(struct, {
            "proj": {"tests": {"another.file": "content"}}})

        return struct, opts