def _check_folder_sync(self, expected_actions, fakeargs): # only local file_a = local_file('a.txt', [100]) file_b = local_file('b.txt', [100]) file_d = local_file('d/d.txt', [100]) file_e = local_file('e/e.incl', [100]) # both local and remote file_bi = local_file('b.txt.incl', [100]) file_z = local_file('z.incl', [100]) # only remote file_c = local_file('c.txt', [100]) local_folder = FakeFolder( 'local', [file_a, file_b, file_d, file_e, file_bi, file_z]) b2_folder = FakeFolder('b2', [file_bi, file_c, file_z]) policies_manager = ScanPoliciesManager( exclude_dir_regexes=fakeargs.excludeDirRegex, exclude_file_regexes=fakeargs.excludeRegex, include_file_regexes=fakeargs.includeRegex, exclude_all_symlinks=fakeargs.excludeAllSymlinks) actions = list( make_folder_sync_actions(local_folder, b2_folder, fakeargs, TODAY, self.reporter, policies_manager)) self.assertEqual(expected_actions, [str(a) for a in actions])
def _check_one_file(self, src_type, src_file, dst_type, dst_file, args, expected_actions): """ Checks the actions generated for one file. The file may or may not exist at the source, and may or may not exist at the destination. Passing in None means that the file does not exist. The source and destination files may have multiple versions. """ src_folder = FakeFolder(src_type, [src_file] if src_file else []) dst_folder = FakeFolder(dst_type, [dst_file] if dst_file else []) actions = list( make_folder_sync_actions(src_folder, dst_folder, args, TODAY, self.reporter)) action_strs = [str(a) for a in actions] if expected_actions != action_strs: print('Expected:') for a in expected_actions: print(' ', a) print('Actual:') for a in action_strs: print(' ', a) self.assertEqual(expected_actions, [str(a) for a in actions])
def test_illegal_local_to_local(self): local_folder = FakeFolder('local', []) with self.assertRaises(NotImplementedError): list( make_folder_sync_actions(local_folder, local_folder, FakeArgs(), 0, self.reporter))
def test_illegal_b2_to_b2(self): b2_folder = FakeFolder('b2', []) with self.assertRaises(NotImplementedError): list( make_folder_sync_actions(b2_folder, b2_folder, FakeArgs(), 0, self.reporter))