| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
import os |
| 11 |
import shutil |
| 12 |
|
| 13 |
from rsyncfns import FROMDIR, TMPDIR, TODIR, checkit, hands_setup, run_rsync |
| 14 |
|
| 15 |
|
| 16 |
hands_setup() |
| 17 |
|
| 18 |
DEBUG_OPTS = "--debug=all0,deltasum0" |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
print("Test basic operation:") |
| 23 |
checkit(['-av', f'{FROMDIR}/', str(TODIR)], FROMDIR, TODIR) |
| 24 |
|
| 25 |
he |
| 26 |
|
| 27 |
os.link(FROMDIR / 'filelist', FROMDIR / 'dir' / 'filelist') |
| 28 |
print("Test hard links:") |
| 29 |
checkit(['-avH', '--bwlimit=0', DEBUG_OPTS, f'{FROMDIR}/', str(TODIR)], FROMDIR, TODIR) |
| 30 |
|
| 31 |
ld |
| 32 |
|
| 33 |
(TODIR / 'text').unlink() |
| 34 |
print("Test one file:") |
| 35 |
checkit(['-avH', DEBUG_OPTS, f'{FROMDIR}/', str(TODIR)], FROMDIR, TODIR) |
| 36 |
|
| 37 |
so |
| 38 |
|
| 39 |
with open(TODIR / 'text', 'a') as f: |
| 40 |
f.write("extra line\n") |
| 41 |
print("Test extra data:") |
| 42 |
checkit(['-avH', DEBUG_OPTS, '--no-whole-file', f'{FROMDIR}/', str(TODIR)], FROMDIR, TODIR) |
| 43 |
|
| 44 |
te |
| 45 |
|
| 46 |
shutil.copy(FROMDIR / 'text', TODIR / 'ThisShouldGo') |
| 47 |
print("Test --delete:") |
| 48 |
checkit(['--delete', '-avH', DEBUG_OPTS, f'{FROMDIR}/', str(TODIR)], FROMDIR, TODIR) |
| 49 |
|
| 50 |
by |
| 51 |
|
| 52 |
os.chdir(TMPDIR) |
| 53 |
shutil.rmtree('to', ignore_errors=True) |
| 54 |
for entry in TMPDIR.glob('from/*dir'): |
| 55 |
if entry.is_dir(): |
| 56 |
shutil.rmtree(entry, ignore_errors=True) |
| 57 |
else: |
| 58 |
entry.unlink() |
| 59 |
|
| 60 |
y. |
| 61 |
sources = sorted(str(p) for p in (TMPDIR / 'from').iterdir()) |
| 62 |
run_rsync('-av', *sources, 'to/') |
| 63 |
checkit(['-av', '--exclude=*', 'from/', 'to/'], FROMDIR, TODIR) |