Skip to content

Commit e1c55a2

Browse files
committed
some e2e tests [ugly_sync_tests]
1 parent 808e567 commit e1c55a2

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

‎test_sync.py‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import tempfile
2+
from pathlib import Path
3+
import shutil
4+
from sync import sync
5+
6+
def test_when_a_file_exists_in_the_source_but_not_the_destination():
7+
try:
8+
source = tempfile.mkdtemp()
9+
dest = tempfile.mkdtemp()
10+
11+
content = "I am a very useful file"
12+
(Path(source) / 'my-file').write_text(content)
13+
14+
sync(source, dest)
15+
16+
expected_path = Path(dest) / 'my-file'
17+
assert expected_path.exists()
18+
assert expected_path.read_text() == content
19+
20+
finally:
21+
shutil.rmtree(source)
22+
shutil.rmtree(dest)
23+
24+
25+
def test_when_a_file_has_been_renamed_in_the_source():
26+
try:
27+
source = tempfile.mkdtemp()
28+
dest = tempfile.mkdtemp()
29+
30+
content = "I am a file that was renamed"
31+
source_path = Path(source) / 'source-filename'
32+
old_dest_path = Path(dest) / 'dest-filename'
33+
expected_dest_path = Path(dest) / 'source-filename'
34+
source_path.write_text(content)
35+
old_dest_path.write_text(content)
36+
37+
sync(source, dest)
38+
39+
assert old_dest_path.exists() is False
40+
assert expected_dest_path.read_text() == content
41+
42+
43+
finally:
44+
shutil.rmtree(source)
45+
shutil.rmtree(dest)
46+

0 commit comments

Comments
 (0)