def test_merge_changes_move_server(self): server_changes = { **h_create_folder_entry( gen_paths.normalize_path("folder1"), { **h_create_change(gen_paths.NormalizedPath("test.txt"), gen_json.ACTION_MOVE, new_file_path=gen_paths.normalize_path("new_test.txt")) }) } client_changes = h_create_folder_entry( gen_paths.normalize_path(client_paths.LOCAL_CLIENT_DATA, "folder1"), {}, gen_paths.normalize_path("folder1")) expected_server = [] expected_conflicts = [] expected_client = [ c_sync.create_action( gen_paths.normalize_path(client_paths.LOCAL_CLIENT_DATA, "folder1"), gen_paths.normalize_path("new_test.txt"), gen_json.ACTION_MOVE, rel_old_file_path=gen_paths.normalize_path("test.txt")) ] self.h_check_merge(server_changes, client_changes, expected_server, expected_client, expected_conflicts)
def h_create_dummy_client_change_file(): dummy_changes = {} rel_entry_path = gen_paths.NormalizedPath("test_1.txt") action_type = gen_json.ACTION_PULL is_dir = False new_file_path = None gen_json._add_new_change_entry(dummy_changes, rel_entry_path, action_type, is_dir, new_file_path) return dummy_changes.popitem()
def test_execute_client_actions_pull(self): self.server_folder = h_setup_execution_env() server_file_path = os.path.join(self.server_folder, 'test.txt') with open(server_file_path, "w") as f: f.write("Hello" * 10) client_actions = [ c_sync.create_action( gen_paths.normalize_path(client_paths.LOCAL_CLIENT_DATA, "folder1"), gen_paths.normalize_path("test.txt"), gen_json.ACTION_PULL, remote_abs_path=gen_paths.NormalizedPath("folder1/test.txt")) ] c_sync.execute_client_actions(client_actions) client_dest_path = os.path.join(client_paths.LOCAL_CLIENT_DATA, "folder1/test.txt") self.assertTrue(os.path.isfile(client_dest_path))
def test_merge_changes_delete_client(self): client_changes = { **h_create_folder_entry( gen_paths.normalize_path(client_paths.LOCAL_CLIENT_DATA, "folder1"), { **h_create_change(gen_paths.NormalizedPath("test.txt"), gen_json.ACTION_DELETE) }, gen_paths.normalize_path("folder1")) } server_changes = h_create_folder_entry( gen_paths.normalize_path("folder1"), {}) expected_server = [ c_sync.create_action(gen_paths.normalize_path("folder1"), gen_paths.normalize_path("test.txt"), gen_json.ACTION_DELETE) ] expected_client = [] expected_conflicts = [] self.h_check_merge(server_changes, client_changes, expected_server, expected_client, expected_conflicts)