IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40958


Ignore:
Timestamp:
Oct 21, 2019, 11:38:13 AM (7 years ago)
Author:
fairlamb
Message:

Added simple class for all the other backups + tests. Test configs approximate current setup

Location:
branches/ipp-259_genericise_backups/tools/backups
Files:
9 added
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ipp-259_genericise_backups/tools/backups/svn_backup_test.py

    r40952 r40958  
    3636
    3737
     38class TestSvnCopy(object):
     39    """Simple inherit of base class Backup"""
     40
     41    # Setup config
     42    def test_copy(self, tmpdir):
     43        backup_1_path = os.path.join(tmpdir, "backup_1_path")
     44        backup_2_path = os.path.join(tmpdir, "backup_2_path")
     45        config = configparser.ConfigParser()
     46        config['DEFAULT'] = \
     47            { 'backup_paths' :  f"{backup_1_path}, {backup_2_path}"
     48            , 'source_machine' : 'rocket'
     49            , 'verbose' : 'True'
     50            }
     51        config['COPY'] = \
     52            { 'sources' : f"{os.path.join(tmpdir, 'apache2/mods-enabled/dav_svn.conf')}"
     53            , 'additional_args' : "-v"
     54            }
     55        backup_1_path = os.path.join(tmpdir, "backup_1_path")
     56        backup_2_path = os.path.join(tmpdir, "backup_2_path")
     57        os.makedirs(backup_1_path)
     58        os.makedirs(backup_2_path)
     59
     60        # Create files to be Rync'd
     61        apache_folder = os.path.join(tmpdir, "apache2")
     62        subdir = os.path.join(apache_folder, "mods-enabled")
     63        file = os.path.join(subdir, "dav_svn.conf")
     64        os.makedirs(apache_folder)
     65        os.makedirs(subdir)
     66        Path(file).touch()
     67
     68        # Setup Schema
     69        schema = ConfigSchema(None)
     70        schema.add_section(bckup.DEFAULT_SCHEMA_SECTION)
     71        schema.add_section(bckup.COPY_SCHEMA_SECTION)
     72
     73        # check that the rsync is successful (with options)
     74        sb = SvnBackup(config, schema)
     75
     76        expected_file_bck1 = os.path.join(tmpdir, 'backup_1_path', 'dav_svn.conf')
     77        expected_file_bck2 = os.path.join(tmpdir, 'backup_2_path', 'dav_svn.conf')
     78        assert not os.path.exists(expected_file_bck1)
     79        assert not os.path.exists(expected_file_bck2)
     80        sb._run_copy()
     81        assert os.path.exists(expected_file_bck1)
     82        assert os.path.exists(expected_file_bck2)
     83
     84
    3885class TestSvnRsync(object):
     86    """Simple inherit of base class Backup"""
    3987
    4088    def test_rsync_with_additional_args(self, tmpdir):
Note: See TracChangeset for help on using the changeset viewer.