def b2_file(name, mod_times, size=10): """ Makes a File object for a b2 file, with one FileVersion for each modification time given in mod_times. Positive modification times are uploads, and negative modification times are hides. It's a hack, but it works. b2_file('a.txt', [300, -200, 100]) Is the same as: File( 'a.txt', [ FileVersion('id_a_300', 'a.txt', 300, 'upload'), FileVersion('id_a_200', 'a.txt', 200, 'hide'), FileVersion('id_a_100', 'a.txt', 100, 'upload') ] ) """ versions = [ FileVersion( 'id_%s_%d' % (name[0], abs(mod_time)), 'folder/' + name, abs(mod_time), 'upload' if 0 < mod_time else 'hide', size, ) for mod_time in mod_times ] # yapf disable return File(name, versions)
def local_file(name, mod_times, size=10): """ Makes a File object for a b2 file, with one FileVersion for each modification time given in mod_times. """ versions = [ FileVersion('/dir/%s' % (name, ), name, mod_time, 'upload', size) for mod_time in mod_times ] return File(name, versions)
def test_two(self): file_a1 = File("a.txt", [FileVersion("a", "a", 100, "upload", 10)]) file_a2 = File("b.txt", [FileVersion("b", "b", 100, "upload", 10)]) file_a3 = File("d.txt", [FileVersion("c", "c", 100, "upload", 10)]) file_a4 = File("f.txt", [FileVersion("f", "f", 100, "upload", 10)]) file_b1 = File("b.txt", [FileVersion("b", "b", 200, "upload", 10)]) file_b2 = File("e.txt", [FileVersion("e", "e", 200, "upload", 10)]) folder_a = FakeFolder('b2', [file_a1, file_a2, file_a3, file_a4]) folder_b = FakeFolder('b2', [file_b1, file_b2]) self.assertEqual([(file_a1, None), (file_a2, file_b1), (file_a3, None), (None, file_b2), (file_a4, None)], list(zip_folders(folder_a, folder_b, self.reporter)))
def test_one_empty(self): file_a1 = File("a.txt", [FileVersion("a", "a", 100, "upload", 10)]) folder_a = FakeFolder('b2', [file_a1]) folder_b = FakeFolder('b2', []) self.assertEqual([(file_a1, None)], list(zip_folders(folder_a, folder_b, self.reporter)))