예제 #1
0
 def test_invalid_dates(self):
     """Make sure filenames with invalid dates don't cause an exception."""
     with TemporaryDirectory(prefix='rotate-backups-', suffix='-test-suite') as root:
         file_with_valid_date = os.path.join(root, 'snapshot-201808030034.tar.gz')
         file_with_invalid_date = os.path.join(root, 'snapshot-180731150101.tar.gz')
         for filename in file_with_valid_date, file_with_invalid_date:
             touch(filename)
         program = RotateBackups(rotation_scheme=dict(monthly='always'))
         backups = program.collect_backups(root)
         assert len(backups) == 1
         assert backups[0].pathname == file_with_valid_date
예제 #2
0
 def test_invalid_dates(self):
     """Make sure filenames with invalid dates don't cause an exception."""
     with TemporaryDirectory(prefix='rotate-backups-',
                             suffix='-test-suite') as root:
         file_with_valid_date = os.path.join(
             root, 'snapshot-201808030034.tar.gz')
         file_with_invalid_date = os.path.join(
             root, 'snapshot-180731150101.tar.gz')
         for filename in file_with_valid_date, file_with_invalid_date:
             touch(filename)
         program = RotateBackups(rotation_scheme=dict(monthly='always'))
         backups = program.collect_backups(root)
         assert len(backups) == 1
         assert backups[0].pathname == file_with_valid_date
예제 #3
0
def find_snapshots(directory):
    """Abuse :mod:`rotate_backups` to scan a directory for snapshots."""
    helper = RotateBackups(DEFAULT_ROTATION_SCHEME)
    return helper.collect_backups(directory)