Skip to content

Commit

Permalink
Add unit tests for deduplicate conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mia A authored and Mia A committed Aug 4, 2024
1 parent e9cbc90 commit 31aeec5
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/actions/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,44 @@ def test_copy_conflict(fs, mode, result):
Config.from_string(config).execute(simulate=False)
assert read_files("test") == result

def test_copy_deduplicate_conflict(fs):
files = {
"src.txt": "src",
"duplicate": {
"src.txt": "src",
},
"nonduplicate": {
"src.txt": "src2",
},
}

config = """
rules:
- locations: "/test"
subfolders: true
filters:
- name: src
actions:
- copy:
dest: "/test/dst.txt"
on_conflict: deduplicate
"""
make_files(files, "test")

Config.from_string(config).execute(simulate=False)
result = read_files("test")

assert result == {
"src.txt": "src",
"duplicate": {
"src.txt": "src",
},
"nonduplicate": {
"src.txt": "src2",
},
"dst.txt": "src",
"dst 2.txt": "src2",
}

def test_does_not_create_folder_in_simulation(fs):
config = """
Expand Down
35 changes: 35 additions & 0 deletions tests/actions/test_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,41 @@ def test_move_conflict(fs, mode, result):
Config.from_string(config).execute(simulate=False)
assert read_files("test") == result

def test_move_deduplicate_conflict(fs):
files = {
"src.txt": "src",
"duplicate": {
"src.txt": "src",
},
"nonduplicate": {
"src.txt": "src2",
},
}

config = """
rules:
- locations: "/test"
subfolders: true
filters:
- name: src
actions:
- move:
dest: "/test/dst.txt"
on_conflict: deduplicate
"""
make_files(files, "test")

Config.from_string(config).execute(simulate=False)
result = read_files("test")

assert result == {
"duplicate": {
"src.txt": "src",
},
"nonduplicate": {},
"dst.txt": "src",
"dst 2.txt": "src2",
}

def test_move_folder_conflict(fs):
make_files(
Expand Down

0 comments on commit 31aeec5

Please sign in to comment.