def test_handle_destination_dir_data_sync(self, mock_copy_file): """ Test 'handle_destination_dir_data' synchronizes unmatched destination data to source. """ sync = Sync(FAKE_MTP_DETAILS, "/tmp", "Card/Music", unmatched=SYNCHRONIZE) sync.set_source_abs() sync.set_destination_abs() sync.handle_destination_dir_data({ "src_dir_abs": "/tmp/testdir", "dst_dir_fls": [ "/run/user/<user>/gvfs/mtp:host=%5Busb%3A002%2C003%5D/Card/Music/testdir/song.mp3" # noqa ], "dst_dir_abs": "/run/user/<user>/gvfs/mtp:host=%5Busb%3A002%2C003%5D/Card/Music/testdir", # noqa }) mock_copy_file.assert_called_once_with( dst_file="/tmp/testdir/song.mp3", src_file= "/run/user/<user>/gvfs/mtp:host=%5Busb%3A002%2C003%5D/Card/Music/testdir/song.mp3", # noqa )
def test_handle_destination_dir_data_no_files(self, mock_gfvs_wrapper): """ Test 'handle_destination_dir_data' ends early when there are no data to process. """ sync = Sync(FAKE_MTP_DETAILS, "/tmp", "Card/Music", unmatched=REMOVE) sync.set_source_abs() sync.set_destination_abs() sync.handle_destination_dir_data({"dst_dir_fls": []}) mock_gfvs_wrapper.assert_not_called()
def test_handle_destination_dir_data_remove(self, mock_gfvs_wrapper): """ Test 'handle_destination_dir_data' removes unmatched destination data. """ sync = Sync(FAKE_MTP_DETAILS, "/tmp", "Card/Music", unmatched=REMOVE) sync.set_source_abs() sync.set_destination_abs() sync.handle_destination_dir_data({ "dst_dir_fls": [ "/run/user/<user>/gvfs/mtp:host=%5Busb%3A002%2C003%5D/Card/Music/testdir/song.mp3" # noqa ] }) mock_gfvs_wrapper.assert_called_once_with( rm, "/run/user/<user>/gvfs/mtp:host=%5Busb%3A002%2C003%5D/Card/Music/testdir/song.mp3", # noqa )