- Timestamp:
- Oct 18, 2019, 2:55:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ipp-259_genericise_backups/tools/backups/backup_test.py
r40949 r40951 8 8 import backups.utils.errors as errs 9 9 from backups.backup import Backup 10 from backups.utils.config_parse_helper import ConfigSchema 10 from backups.utils.config_parse_helper import ConfigSchema, ConfigSchemaSection, ConfigSchemaLine 11 11 12 12 TEST_DEFAULT_CONFIG_FILE = os.path.join(os.path.dirname(__file__), 'testing/backup_test.config') … … 486 486 backy._run_rsync() 487 487 488 def test_rsync_requires_dash_r_arg_for_copying_ dirs(self, tmpdir):488 def test_rsync_requires_dash_r_arg_for_copying_only_dirs(self, tmpdir): 489 489 config = make_default_config(tmpdir, ['bck1', 'bck2']) 490 490 source = os.path.join(tmpdir, "some_dir") … … 521 521 assert os.path.exists(expected1dir) 522 522 assert os.path.exists(expected2dir) 523 524 def test_rsync_with_delete_after_options(self, tmpdir): 525 config = make_default_config(tmpdir, ['bck1', 'bck2']) 526 source_dir = os.path.join(tmpdir, "some_dir") 527 source_file1 = os.path.join(source_dir, "file1") 528 source_file2 = os.path.join(source_dir, "file2") 529 source_file3 = os.path.join(source_dir, "file3") 530 config['RSYNC'] = \ 531 { 'sources' : f"{source_dir}" 532 , 'additional_args' : "-v -z -r --progress" 533 } 534 535 os.makedirs(source_dir) 536 Path(source_file1).touch() 537 Path(source_file2).touch() 538 Path(source_file3).touch() 539 540 schema = ConfigSchema(None) 541 schema.add_section(bckup.DEFAULT_SCHEMA_SECTION) 542 schema.add_section(bckup.RSYNC_SCHEMA_SECTION) 543 544 backy = Backup(config, schema) 545 546 expected1dir = os.path.join(tmpdir, 'bck1', 'some_dir', 'file1') 547 expected2dir = os.path.join(tmpdir, 'bck1', 'some_dir', 'file2') 548 expected3dir = os.path.join(tmpdir, 'bck1', 'some_dir', 'file3') 549 assert not os.path.exists(expected1dir) 550 assert not os.path.exists(expected2dir) 551 assert not os.path.exists(expected3dir) 552 backy._run_rsync() 553 print(expected1dir) 554 assert os.path.exists(expected1dir) 555 assert os.path.exists(expected2dir) 556 assert os.path.exists(expected3dir) 557 558 # Delete two files, create a new one. 559 os.remove(source_file2) 560 os.remove(source_file3) 561 source_file4 = os.path.join(source_dir, "file4") 562 Path(source_file4).touch() 563 expected4dir = os.path.join(tmpdir, 'bck1', 'some_dir', 'file4') 564 565 # Rsync will add 4, and 2 and 3 should still exist 566 backy._run_rsync() 567 assert os.path.exists(expected1dir) 568 assert os.path.exists(expected2dir) 569 assert os.path.exists(expected3dir) 570 assert os.path.exists(expected4dir) 571 572 # with delete after option removed files are cleaned up 573 config['RSYNC'] = \ 574 { 'sources' : f"{source_dir}" 575 , 'additional_args' : '-v -z -r --delete-after' 576 } 577 backy = Backup(config, schema) 578 backy._run_rsync() 579 assert os.path.exists(expected1dir) 580 assert not os.path.exists(expected2dir) 581 assert not os.path.exists(expected3dir) 582 assert os.path.exists(expected4dir) 583 523 584 524 585
Note:
See TracChangeset
for help on using the changeset viewer.
