Exemple #1
0
    def test_restore_full(self, target):
        io = self.get_io(target)

        bak = self.get_valid(io)
        status = bak.restore(context.TMP_DIR)

        self.assertEqual(status.exit_code, 0)

        expected_data = test_utils.get_dir_struct(bak.backup_data_dir)
        synced_data = test_utils.get_dir_struct(context.TMP_DIR)
        self.assertEqual(expected_data, synced_data)

        io.close()
Exemple #2
0
    def test_restore_items(self, target):
        io = self.get_io(target)

        bak = self.get_valid(io)
        status = bak.restore(context.TMP_DIR, ['/tmp/test1.file'])

        self.assertEqual(status.exit_code, 0)

        expected_data = test_utils.get_dir_struct(bak.backup_data_dir)
        del expected_data['tmp']['test2.file']
        del expected_data['tmp']['test3.file']

        synced_data = test_utils.get_dir_struct(context.TMP_DIR)
        self.assertEqual(expected_data, synced_data)

        io.close()
Exemple #3
0
    def test_backup_special_char(self, target):
        io = self.get_io(target)

        bak = backup.Backup.new(io, context.BACKUP_DIR)
        status = bak.backup([context.SPECIAL_FILE.decode()])

        self.assertEqual(status.exit_code, 0)

        # Define the structure we expect after the backup
        expected_data = test_utils.get_dir_struct(context.DATA_DIR)
        del expected_data['test.dir']
        del expected_data['test.file']

        real_data_dir = os.path.join(bak.backup_data_dir,
                                     context.DATA_DIR.lstrip('/'))

        synced_data = test_utils.get_dir_struct(real_data_dir)
        self.assertEqual(expected_data, synced_data)

        io.close()
Exemple #4
0
    def test_backup_pattern(self, target):
        io = self.get_io(target)

        bak = backup.Backup.new(io, context.BACKUP_DIR)
        status = bak.backup([os.path.join(context.DATA_DIR, 'test*')],
                            excludes=['**/dir2'])

        self.assertEqual(status.exit_code, 0)

        # Define the structure we expect after the backup
        expected_data = test_utils.get_dir_struct(context.DATA_DIR.encode())
        del expected_data[b'test.dir'][b'dir2']
        del expected_data[context.SPECIAL_NAME]

        real_data_dir = os.path.join(bak.backup_data_dir,
                                     context.DATA_DIR.lstrip('/'))

        synced_data = test_utils.get_dir_struct(real_data_dir.encode())
        self.assertEqual(expected_data, synced_data)

        io.close()
Exemple #5
0
    def test_remote_special_char(self):
        sync = rsync.rsync()
        sync.dry_run = False

        # Define the structure we expect after synchronizing
        expected_data = self.data_dir_struct
        del expected_data[b'test.dir']
        del expected_data[b'test.file']

        # Send the files
        target = rsync.Path(context.TMP_DIR, context.SSH_HOST)
        sync.sync(target, [context.SPECIAL_FILE.decode()])

        # Get and compare the structure of our sync target
        synced_data = test_utils.get_dir_struct(self.real_target.encode())
        self.assertEqual(expected_data, synced_data)
Exemple #6
0
    def test_remote_simple(self):
        sync = rsync.rsync()
        sync.dry_run = False

        # Define the structure we expect after synchronizing
        expected_data = self.data_dir_struct
        del expected_data[b'test.dir'][b'dir2']
        del expected_data[context.SPECIAL_NAME]

        # Send the files
        target = rsync.Path(context.TMP_DIR, context.SSH_HOST)
        sync.sync(target, [context.TEST_DIR, context.TEST_FILE],
                  excludes=['**/dir2/.gitkeep'])

        # Get and compare the structure of our sync target
        synced_data = test_utils.get_dir_struct(self.real_target.encode())
        self.assertEqual(expected_data, synced_data)
Exemple #7
0
 def data_dir_struct(self):
     return test_utils.get_dir_struct(context.DATA_DIR.encode())