IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 5, 2019, 3:18:35 PM (7 years ago)
Author:
fairlamb
Message:

merge of branch ipp-350 into trunk

Location:
trunk/backups
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/backups

  • trunk/backups/backup_test.py

    r40967 r41067  
    596596        assert os.path.exists(expected4dir)
    597597
     598    def test_rsync_with_subdirs_option(self, tmpdir):
     599        config = make_default_config(tmpdir, ['bck1', 'bck2'])
     600        source1 = os.path.join(tmpdir, "some_dir")
     601        source2 = os.path.join(tmpdir, "some_other_dir")
     602        file_in_dir = os.path.join(source1, "and_specific_file.jpeg")
     603        file_in_other_dir = os.path.join(source2, "another_file.jpeg")
     604        os.makedirs(source1)
     605        os.makedirs(source2)
     606        Path(file_in_dir).touch()
     607        Path(file_in_other_dir).touch()
     608
     609        config['RSYNC'] = \
     610        { 'sources' : f"{source1}, {source2}"
     611        , 'additional_args' : "-a --progress -v"
     612        , 'sub-dirs' : "subdir_with_better_name1, subdir_with_better_name2"
     613        }
     614
     615        schema = ConfigSchema(None)
     616        schema.add_section(bckup.DEFAULT_SCHEMA_SECTION)
     617        schema.add_section(bckup.RSYNC_SCHEMA_SECTION)
     618
     619        backy = Backup(config, schema)
     620
     621        expected_bak1_src1_dir  = os.path.join(tmpdir, 'bck1', 'subdir_with_better_name1', 'some_dir')
     622        expected_bak1_src1_file = os.path.join(tmpdir, 'bck1', 'subdir_with_better_name1', 'some_dir', 'and_specific_file.jpeg')
     623        expected_bak1_src2_dir  = os.path.join(tmpdir, 'bck1', 'subdir_with_better_name2', 'some_other_dir')
     624        expected_bak1_src2_file = os.path.join(tmpdir, 'bck1', 'subdir_with_better_name2', 'some_other_dir', 'another_file.jpeg')
     625        expected_bak2_src1_dir  = os.path.join(tmpdir, 'bck2', 'subdir_with_better_name1', 'some_dir')
     626        expected_bak2_src1_file = os.path.join(tmpdir, 'bck2', 'subdir_with_better_name1', 'some_dir', 'and_specific_file.jpeg')
     627        expected_bak2_src2_dir  = os.path.join(tmpdir, 'bck2', 'subdir_with_better_name2', 'some_other_dir')
     628        expected_bak2_src2_file = os.path.join(tmpdir, 'bck2', 'subdir_with_better_name2', 'some_other_dir', 'another_file.jpeg')
     629        assert not os.path.exists(expected_bak1_src1_dir)
     630        assert not os.path.exists(expected_bak1_src1_file)
     631        assert not os.path.exists(expected_bak1_src2_dir)
     632        assert not os.path.exists(expected_bak1_src2_file)
     633        assert not os.path.exists(expected_bak2_src1_dir)
     634        assert not os.path.exists(expected_bak2_src1_file)
     635        assert not os.path.exists(expected_bak2_src2_dir)
     636        assert not os.path.exists(expected_bak2_src2_file)
     637        backy._run_rsync()
     638        assert os.path.exists(expected_bak1_src1_dir)
     639        assert os.path.exists(expected_bak1_src1_file)
     640        assert os.path.exists(expected_bak1_src2_dir)
     641        assert os.path.exists(expected_bak1_src2_file)
     642        assert os.path.exists(expected_bak2_src1_dir)
     643        assert os.path.exists(expected_bak2_src1_file)
     644        assert os.path.exists(expected_bak2_src2_dir)
     645        assert os.path.exists(expected_bak2_src2_file)
    598646
    599647@pytest.mark.skip(reason="Requires a fake database to be setup")
Note: See TracChangeset for help on using the changeset viewer.