Exemplo n.º 1
0
    def test_list_folders_should_return_nothing_given_there_are_no_folders(
            self):
        self.api.list_albums.return_value = []
        storage = GoogleStorage(self.config, self.api)
        folders = list(storage.list_folders())

        assert not folders
Exemplo n.º 2
0
    def test_list_folders_should_return_folders_given_there_are_folders(
            self, folders_fixture):
        self.api.list_albums.return_value = folders_fixture
        storage = GoogleStorage(self.config, self.api)
        folders = list(storage.list_folders())

        assert len(folders) == 2
Exemplo n.º 3
0
    def test_list_files_should_not_list_files_given_there_are_no_files(self):
        self.api.get_media_in_folder.return_value = []
        storage = GoogleStorage(self.config, self.api)
        folder = Folder(id=123, name='test')
        files = list(storage.list_files(folder))

        assert not files
Exemplo n.º 4
0
    def test_list_files_should_return_files_given_there_are_files(
            self, files_fixture):
        self.api.get_media_in_folder.return_value = files_fixture
        storage = GoogleStorage(self.config, self.api)
        folder = Folder(id=123, name='test')
        files = list(storage.list_files(folder))

        assert len(files) == 2
Exemplo n.º 5
0
    def test_list_folders_should_not_list_folder_given_its_not_included(
            self, folders_fixture):
        self.config.include_dir = 'Folder 1'
        self.api.list_albums.return_value = folders_fixture
        storage = GoogleStorage(self.config, self.api)
        folders = list(storage.list_folders())

        assert len(folders) == 1
        assert folders[0].name == 'Folder 1'
Exemplo n.º 6
0
    def test_list_files_should_not_list_file_given_its_excluded(
            self, files_fixture):
        self.config.exclude = 'image1'
        self.api.get_media_in_folder.return_value = files_fixture
        storage = GoogleStorage(self.config, self.api)
        folder = Folder(id=123, name='test')
        files = list(storage.list_files(folder))

        assert len(files) == 1
        assert files[0].name == 'image2.jpg'
Exemplo n.º 7
0
    def test_upload_should_fetch_folder_given_its_not_cached(
            self, folders_fixture):
        self.api.list_albums.return_value = folders_fixture
        storage = GoogleStorage(self.config, self.api)
        folder = folders_fixture[0]
        storage.upload('/', folder['title'], 'micky.jpg', None)

        self.api.list_albums.assert_called_once()
        self.api.create_album.assert_not_called()
        self.api.upload.assert_called_once_with('/', 'micky.jpg', folder['id'])
Exemplo n.º 8
0
 def test_list_files_should_raise_not_implemented_when_root_folder_is_passed(
         self):
     storage = GoogleStorage(self.config, self.api)
     folder = RootFolder()
     with pytest.raises(NotImplementedError):
         _ = list(storage.list_files(folder))