示例#1
0
def test_upload(monkeypatch, parent, mock_client):
    mock = Mock()
    client = GCloudStorageClient('my-bucket-name', parent=parent)
    monkeypatch.setattr(client, '_upload', mock)

    client.upload('file.txt')

    mock.assert_called_once_with('file.txt',
                                 str(PurePosixPath(parent, 'file.txt')))
示例#2
0
def test_upload_file(monkeypatch, parent, mock_client):
    mock = Mock()
    client = GCloudStorageClient('my-bucket-name',
                                 parent=parent,
                                 path_to_project_root='.')
    monkeypatch.setattr(client, '_upload', mock)

    client.upload('file.txt')

    mock.assert_called_once_with('file.txt')
示例#3
0
def test_upload_folder(tmp_directory, monkeypatch, mock_client):
    Path('dir', 'subdir', 'nested').mkdir(parents=True)
    Path('dir', 'a').touch()
    Path('dir', 'b').touch()
    Path('dir', 'subdir', 'c').touch()
    Path('dir', 'subdir', 'nested', 'd').touch()

    mock = Mock()
    client = GCloudStorageClient('my-bucket-name',
                                 parent='.',
                                 path_to_project_root='.')
    monkeypatch.setattr(client, '_upload', mock)

    client.upload('dir')

    mock.assert_has_calls([
        call(str(Path('dir', 'a'))),
        call(str(Path('dir', 'b'))),
        call(str(Path('dir', 'subdir', 'c'))),
        call(str(Path('dir', 'subdir', 'nested', 'd'))),
    ],
                          any_order=True)