Esempio n. 1
0
    def test_get_destination_subdir_data_(self, mock_handle_ignored_file_type,
                                          mock_listdir, mock_path_exists):
        """
        Test 'get_destination_subdir_data' populates 'dst_dir_fls' with
        collected data.
        """
        mock_path_exists.return_value = True
        mock_listdir.return_value = ["song.mp3", "cover.jpg", "demo.mp3"]
        mock_handle_ignored_file_type.side_effect = [
            None,
            IgnoredTypeException,
            None,
        ]

        sync = Sync(FAKE_MTP_DETAILS, "/tmp", "Card/Music")
        sync.set_source_abs()
        sync.set_destination_abs()
        sync_data = self._create_empty_sync_data(sync)
        sync.get_destination_subdir_data(sync_data)

        self.assertEqual(
            sync_data["dst_dir_fls"],
            [
                "/run/user/<user>/gvfs/mtp:host=%5Busb%3A002%2C003%5D/Card/Music/testdir/song.mp3",  # noqa
                "/run/user/<user>/gvfs/mtp:host=%5Busb%3A002%2C003%5D/Card/Music/testdir/demo.mp3",  # noqa
            ],
        )
Esempio n. 2
0
    def test_get_destination_subdir_data_doesnt_exist(self, mock_gvfs_wrapper,
                                                      mock_path_exists):
        """
        Test 'get_destination_subdir_data' creates destination direcotry if it
        doesn't exist.
        """
        mock_path_exists.side_effect = (True, False)

        sync = Sync(FAKE_MTP_DETAILS, "/tmp", "Card/Music")
        sync.set_source_abs()
        sync.set_destination_abs()
        sync_data = self._create_empty_sync_data(sync)
        sync.get_destination_subdir_data(sync_data)

        mock_gvfs_wrapper.assert_called_once_with(
            mkdir,
            "/run/user/<user>/gvfs/mtp:host=%5Busb%3A002%2C003%5D/Card/Music/testdir",  # noqa
        )
        self.assertFalse(sync_data["dst_dir_fls"])