def create_snapshot_with_etags_before_modification():
    metadata = {}
    metadata['file1.txt'] = {'size': 1, 'lmtime': 1, 'etag': 'LAST_ETAG_01'}
    metadata['file2.txt'] = {'size': 2, 'lmtime': 1, 'etag': 'LAST_ETAG_02'}
    pathnames = sorted(metadata.keys())
    snapshot = WareboxSnapshot(pathnames, metadata, None)
    snapshot._dont_copy_below_size = 1
    return snapshot
def create_snapshot_with_etags_after_modification(warebox_mock):
    metadata = {}
    metadata['file1.txt'] = {'size': 1, 'lmtime': 2, 'etag': 'WRONG_ETAG_01'}
    metadata['file2.txt'] = {'size': 2, 'lmtime': 1, 'etag': 'WRONG_ETAG_02'}
    pathnames = sorted(metadata.keys())
    snapshot = WareboxSnapshot(pathnames, metadata, warebox_mock)
    snapshot._dont_copy_below_size = 1
    return snapshot
def create_snapshot_with_hierarchy_before_modification():
    metadata = {}
    metadata['folder1/']          = { 'size': 0, 'lmtime': 0, 'etag': 'ETAG00' }
    metadata['folder1/file.txt']  = { 'size': 2, 'lmtime': 0, 'etag': 'ETAG01' }
    metadata['folder5/']          = { 'size': 0, 'lmtime': 0, 'etag': 'ETAG00' }
    metadata['folder5/file.txt']  = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG05' }
    pathnames = sorted(metadata.keys())
    snapshot = WareboxSnapshot(pathnames, metadata, None)
    snapshot._dont_copy_below_size = 1
    return snapshot
def create_snapshot_before_modification():
    metadata = {}
    metadata['file1.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG01' }
    metadata['file2.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG02' }
    metadata['file3.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG03' }
    metadata['file4.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG0B' }
    metadata['file5.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG04' }
    metadata['file6.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG05' }
    metadata['file7.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG06' }
    metadata['fileC.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG06' }
    pathnames = sorted(metadata.keys())
    snapshot = WareboxSnapshot(pathnames, metadata, None)
    snapshot._dont_copy_below_size = 1
    return snapshot
def create_snapshot_with_hierarchy_after_modification():
    metadata = {}
    metadata['folder1/']          = {'size': 0, 'lmtime': 0, 'etag': 'ETAG00'}  # normal
    metadata['folder1/file.txt']  = {'size': 1, 'lmtime': 0, 'etag': 'ETAG01'}  # normal
    metadata['folder2/']          = {'size': 0, 'lmtime': 0, 'etag': 'ETAG00'}  # new
    metadata['folder2/file.txt']  = {'size': 3, 'lmtime': 0, 'etag': 'ETAG02'}  # new
    metadata['folder3/']          = {'size': 0, 'lmtime': 0, 'etag': 'ETAG00'}  # copied from last
    metadata['folder3/file.txt']  = {'size': 2, 'lmtime': 0, 'etag': 'ETAG01'}  # copied from last
    metadata['folder4/']          = {'size': 0, 'lmtime': 0, 'etag': 'ETAG00'}  # copied from curr
    metadata['folder4/file.txt']  = {'size': 3, 'lmtime': 0, 'etag': 'ETAG02'}  # copied from curr
    # folder5/ deleted
    # folder5/file.txt deleted
    pathnames = sorted(metadata.keys())
    snapshot = WareboxSnapshot(pathnames, metadata, None)
    snapshot._dont_copy_below_size = 1
    return snapshot
def create_snapshot_with_different_filesizes():
    metadata = {}
    metadata['file1.txt'] = { 'size': 1 }
    metadata['file2.txt'] = { 'size': 9 }
    metadata['file3.txt'] = { 'size': 10 }
    metadata['file4.txt'] = { 'size': 11 }
    metadata['file5.txt'] = { 'size': 99 }
    metadata['file6.txt'] = { 'size': 100 }
    metadata['file7.txt'] = { 'size': 101 }
    metadata['file8.txt'] = { 'size': 999 }
    metadata['file9.txt'] = { 'size': 1000 }
    metadata['fileA.txt'] = { 'size': 1001 }
    metadata['fileA.txt'] = { 'size': 9999 }
    metadata['dir1/'] = { 'size': 0 }
    metadata['dir1/file1.txt'] = { 'size': 1 }
    metadata['dir1/file1.txt'] = { 'size': 5 }
    metadata['dir1/file1.txt'] = { 'size': 9 }
    metadata['dir1/dir2/'] = { 'size': 0 }
    metadata['dir1/dir2/file1.txt'] = { 'size': 10 }
    metadata['dir1/dir2/file2.txt'] = { 'size': 50 }
    metadata['dir1/dir2/file3.txt'] = { 'size': 99 }
    metadata['dir1/dir2/dir3/'] = { 'size': 0 }
    metadata['dir1/dir2/dir3/file1.txt'] = { 'size': 100 }
    metadata['dir1/dir2/dir3/file2.txt'] = { 'size': 500 }
    metadata['dir1/dir2/dir3/file3.txt'] = { 'size': 999 }
    for pathname in metadata:
        metadata[pathname]['lmtime'] = 0
        metadata[pathname]['etag'] = ''
    pathnames = metadata.keys()
    random.shuffle(pathnames)
    snapshot = WareboxSnapshot(pathnames, metadata, None)
    return snapshot
def create_snapshot_after_modification():
    metadata = {}
    metadata['file0.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG00' } # new
    metadata['file1.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG01' } # unchanged
    metadata['file2.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG12' } # modified (etag)
    metadata['file3.txt'] = { 'size': 3, 'lmtime': 0, 'etag': 'ETAG13' } # modified (etag+size)
    metadata['file4.txt'] = { 'size': 2, 'lmtime': 0, 'etag': 'ETAG0B' } # modified (size)
    metadata['file5.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG02' } # modified but copyable from "before"
    # file6.txt deleted
    metadata['file7.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG12' } # modified but copyable from "after"
    # fileC.txt deleted
    metadata['file8.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG01' } # new but copyable from "before"
    metadata['file9.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG06' } # renamed
    metadata['fileA.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG12' } # new but copyable from "after"
    metadata['fileB.txt'] = { 'size': 1, 'lmtime': 0, 'etag': 'ETAG00' } # new but copyable from "after"
    pathnames = sorted(metadata.keys())
    snapshot = WareboxSnapshot(pathnames, metadata, None)
    snapshot._dont_copy_below_size = 1
    return snapshot