File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import tempfile
2+ from pathlib import Path
3+ import shutil
4+ from sync import sync
5+
6+
7+ def test_when_a_file_exists_in_the_source_but_not_the_destination ():
8+ try :
9+ source = tempfile .mkdtemp ()
10+ dest = tempfile .mkdtemp ()
11+
12+ content = "I am a very useful file"
13+ (Path (source ) / "my-file" ).write_text (content )
14+
15+ sync (source , dest )
16+
17+ expected_path = Path (dest ) / "my-file"
18+ assert expected_path .exists ()
19+ assert expected_path .read_text () == content
20+
21+ finally :
22+ shutil .rmtree (source )
23+ shutil .rmtree (dest )
24+
25+
26+ def test_when_a_file_has_been_renamed_in_the_source ():
27+ try :
28+ source = tempfile .mkdtemp ()
29+ dest = tempfile .mkdtemp ()
30+
31+ content = "I am a file that was renamed"
32+ source_path = Path (source ) / "source-filename"
33+ old_dest_path = Path (dest ) / "dest-filename"
34+ expected_dest_path = Path (dest ) / "source-filename"
35+ source_path .write_text (content )
36+ old_dest_path .write_text (content )
37+
38+ sync (source , dest )
39+
40+ assert old_dest_path .exists () is False
41+ assert expected_dest_path .read_text () == content
42+
43+ finally :
44+ shutil .rmtree (source )
45+ shutil .rmtree (dest )
You can’t perform that action at this time.
0 commit comments