Here are the examples of the python api aiohttpretty.register_uri taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
68 Examples
3
Example 1
async def test_upload(self, provider, file_stream, file_metadata):
path = WaterButlerPath('/phile', prepend=provider.folder)
url = provider._webdav_url_ + path.full_path
aiohttpretty.register_uri('PROPFIND', url, body=file_metadata, auto_length=True, status=207)
aiohttpretty.register_uri('PUT', url, body=b'squares', auto_length=True, status=201)
metadata, created = await provider.upload(file_stream, path)
expected = OwnCloudFileMetadata('dissertation.aux','/owncloud/remote.php/webdav/Docuements/phile',
{'{DAV:}getetag':'"a3c411808d58977a9ecd7485b5b7958e"',
'{DAV:}getlastmodified':'Sun, 10 Jul 2016 23:28:31 GMT',
'{DAV:}getcontentlength':3011})
assert created is True
assert metadata.name == expected.name
assert metadata.size == expected.size
assert aiohttpretty.has_call(method='PUT', uri=url)
3
Example 2
async def test_upload_update(self, provider, file_content, file_stream, file_metadata, mock_time):
path = WaterButlerPath('/foobah')
content_md5 = hashlib.md5(file_content).hexdigest()
url = provider.bucket.new_key(path.path).generate_url(100, 'PUT')
metadata_url = provider.bucket.new_key(path.path).generate_url(100, 'HEAD')
aiohttpretty.register_uri('HEAD', metadata_url, headers=file_metadata)
aiohttpretty.register_uri('PUT', url, status=201, headers={'ETag': '"{}"'.format(content_md5)})
metadata, created = await provider.upload(file_stream, path)
assert metadata.kind == 'file'
assert not created
assert aiohttpretty.has_call(method='PUT', uri=url)
assert aiohttpretty.has_call(method='HEAD', uri=metadata_url)
3
Example 3
async def test_delete_file(self, provider, file_metadata):
url = provider.build_url('fileops', 'delete')
path = await provider.validate_path('/The past')
aiohttpretty.register_uri('POST', url, status=200)
await provider.delete(path)
data = {'root': 'auto', 'path': path.full_path}
assert aiohttpretty.has_call(method='POST', uri=url, data=data)
3
Example 4
async def test_delete(monkeypatch, provider, mock_path, mock_time):
path = WaterButlerPath('/unrelatedpath', _ids=('Doesntmatter', 'another'))
params = {'user': 'cat'}
base_url = provider.build_url(path.identifier)
url, _, params = provider.build_signed_url('DELETE', base_url, params=params)
aiohttpretty.register_uri('DELETE', url, params=params, status_code=200)
await provider.delete(path)
assert aiohttpretty.has_call(method='DELETE', uri=url, check_params=False)
3
Example 5
async def test_article_delete(self, article_provider, article_metadata, file_metadata):
file_id = str(file_metadata['id'])
article_id = article_provider.article_id
article_metadata_url = article_provider.build_url('articles', article_id)
article_delete_url = article_provider.build_url('articles', article_id, 'files', file_id)
aiohttpretty.register_uri('DELETE', article_delete_url)
aiohttpretty.register_json_uri('GET', article_metadata_url, body=article_metadata)
path = await article_provider.validate_path('/{}'.format(file_id))
result = await article_provider.delete(path)
assert result is None
assert aiohttpretty.has_call(method='DELETE', uri=article_delete_url)
3
Example 6
async def test_download_not_found(self, provider, native_dataset_metadata):
path = '/21'
url = provider.build_url(dvs.DOWN_BASE_URL, path, key=provider.token)
aiohttpretty.register_uri('GET', url, status=404)
draft_url = provider.build_url(dvs.JSON_BASE_URL.format(provider._id, 'latest'), key=provider.token)
aiohttpretty.register_json_uri('GET', draft_url, status=200, body=native_dataset_metadata)
published_url = provider.build_url(dvs.JSON_BASE_URL.format(provider._id, 'latest-published'), key=provider.token)
aiohttpretty.register_json_uri('GET', published_url, status=200, body=native_dataset_metadata)
path = await provider.validate_path(path)
with pytest.raises(exceptions.DownloadError):
await provider.download(path)
3
Example 7
async def test_download(self, provider, mock_time):
path = WaterButlerPath('/muhtriangle')
url = provider.bucket.new_key(path.path).generate_url(100, response_headers={'response-content-disposition': 'attachment'})
aiohttpretty.register_uri('GET', url, body=b'delicious', auto_length=True)
result = await provider.download(path)
content = await result.read()
assert content == b'delicious'
3
Example 8
async def test_metadata_folder_root_level1_level2(self, connected_provider, folder_root_level1_level2):
path = WaterButlerPath('/level1/level2/')
body = json.dumps(folder_root_level1_level2).encode('utf-8')
url = connected_provider.build_url('', prefix=path.path, delimiter='/')
aiohttpretty.register_uri('GET', url, status=200, body=body)
result = await connected_provider.metadata(path)
assert len(result) == 1
assert result[0].name == 'file2.txt'
assert result[0].path == '/level1/level2/file2.txt'
assert result[0].kind == 'file'
3
Example 9
async def test_metadata_folder_self_listing(self, provider, contents_and_self, mock_time):
path = WaterButlerPath('/thisfolder/')
url = provider.bucket.generate_url(100)
params = build_folder_params(path)
aiohttpretty.register_uri('GET', url, params=params, body=contents_and_self)
result = await provider.metadata(path)
assert isinstance(result, list)
assert len(result) == 2
for fobj in result:
assert fobj.name != path.path
3
Example 10
async def test_metadata_folder_root_level1_empty(self, connected_provider, folder_root_level1_empty):
path = WaterButlerPath('/level1_empty/')
folder_url = connected_provider.build_url('', prefix=path.path, delimiter='/')
folder_body = json.dumps([]).encode('utf-8')
file_url = connected_provider.build_url(path.path.rstrip('/'))
aiohttpretty.register_uri('GET', folder_url, status=200, body=folder_body)
aiohttpretty.register_uri('HEAD', file_url, status=200, headers=folder_root_level1_empty)
result = await connected_provider.metadata(path)
assert result == []
3
Example 11
async def test_delete(self, provider):
item = fixtures.list_file['items'][0]
path = WaterButlerPath('/birdie.jpg', _ids=(None, item['id']))
delete_url = provider.build_url('files', item['id'])
del_url_body = dumps({'labels': {'trashed': 'true'}})
aiohttpretty.register_uri('PUT',
delete_url,
body=del_url_body,
status=200)
result = await provider.delete(path)
assert result is None
assert aiohttpretty.has_call(method='PUT', uri=delete_url)
3
Example 12
async def test_download_by_path_ref_branch(self, provider, repo_tree_metadata_root):
ref = hashlib.sha1().hexdigest()
file_sha = repo_tree_metadata_root['tree'][0]['sha']
path = await provider.validate_path('/file.txt', branch='other_branch')
url = provider.build_repo_url('git', 'blobs', file_sha)
tree_url = provider.build_repo_url('git', 'trees', ref, recursive=1)
commit_url = provider.build_repo_url('commits', path=path.path.lstrip('/'), sha=path.identifier[0])
aiohttpretty.register_uri('GET', url, body=b'delicious')
aiohttpretty.register_json_uri('GET', tree_url, body=repo_tree_metadata_root)
aiohttpretty.register_json_uri('GET', commit_url, body=[{'commit': {'tree': {'sha': ref}}}])
result = await provider.download(path)
content = await result.read()
assert content == b'delicious'
3
Example 13
async def test_metadata_folder_does_not_exist(self, connected_provider):
path = WaterButlerPath('/does_not_exist/')
folder_url = connected_provider.build_url('', prefix=path.path, delimiter='/')
folder_body = json.dumps([]).encode('utf-8')
file_url = connected_provider.build_url(path.path.rstrip('/'))
aiohttpretty.register_uri('GET', folder_url, status=200, body=folder_body)
aiohttpretty.register_uri('HEAD', file_url, status=404)
with pytest.raises(exceptions.MetadataError):
await connected_provider.metadata(path)
3
Example 14
async def test_validate_v1_path_folder(self, provider, folder_metadata):
path = WaterButlerPath('/myfolder/', prepend=provider.folder)
url = provider._webdav_url_ + path.full_path
aiohttpretty.register_uri('PROPFIND', url, body=folder_metadata, auto_length=True, status=207)
try:
wb_path_v1 = await provider.validate_v1_path('/myfolder/')
except Exception as exc:
pytest.fail(str(exc))
wb_path_v0 = await provider.validate_path('/myfolder/')
assert wb_path_v1 == wb_path_v0
3
Example 15
async def test_metadata_folder_root_empty(self, connected_provider, folder_root_empty):
path = WaterButlerPath('/')
body = json.dumps(folder_root_empty).encode('utf-8')
url = connected_provider.build_url(path.path, prefix=path.path, delimiter='/')
aiohttpretty.register_uri('GET', url, status=200, body=body)
result = await connected_provider.metadata(path)
assert len(result) == 0
assert result == []
3
Example 16
async def test_metadata(self, provider, folder_list):
path = WaterButlerPath('/', prepend=provider.folder)
url = provider._webdav_url_ + path.full_path
aiohttpretty.register_uri('PROPFIND', url, body=folder_list, auto_length=True, status=207)
path = await provider.validate_path('/')
url = provider._webdav_url_ + path.full_path
aiohttpretty.register_uri('PROPFIND', url, body=folder_list, status=207)
result = await provider.metadata(path)
assert isinstance(result, list)
assert len(result) == 2
assert result[0].kind == 'folder'
assert result[0].name == 'Docuements'
3
Example 17
Project: waterbutler
License: View license
Source File: test_provider.py
Function: test_download_not_found
License: View license
Source File: test_provider.py
Function: test_download_not_found
async def test_download_not_found(self, provider):
path = await provider.validate_path('/vectors.txt')
url = provider._build_content_url('files', 'auto', path.full_path)
aiohttpretty.register_uri('GET', url, status=404)
with pytest.raises(exceptions.DownloadError) as e:
await provider.download(path)
assert e.value.code == 404
3
Example 18
async def test_download_display_name(self, provider, mock_time):
path = WaterButlerPath('/muhtriangle')
url = provider.bucket.new_key(path.path).generate_url(100, response_headers={'response-content-disposition': "attachment; filename*=UTF-8''tuna"})
aiohttpretty.register_uri('GET', url, body=b'delicious', auto_length=True)
result = await provider.download(path, displayName='tuna')
content = await result.read()
assert content == b'delicious'
3
Example 19
async def test_download(self, connected_provider):
body = b'dearly-beloved'
path = WaterButlerPath('/lets-go-crazy')
url = connected_provider.sign_url(path)
aiohttpretty.register_uri('GET', url, body=body, auto_length=True)
result = await connected_provider.download(path)
content = await result.read()
assert content == body
3
Example 20
async def test_metadata_folder(self, provider, folder_metadata, mock_time):
path = WaterButlerPath('/darp/')
url = provider.bucket.generate_url(100)
params = build_folder_params(path)
aiohttpretty.register_uri('GET', url, params=params, body=folder_metadata,
headers={'Content-Type': 'application/xml'})
result = await provider.metadata(path)
assert isinstance(result, list)
assert len(result) == 3
assert result[0].name == ' photos'
assert result[1].name == 'my-image.jpg'
assert result[2].extra['md5'] == '1b2cf535f27731c974343645a3985328'
3
Example 21
async def test_project_article_download(self, project_provider, list_project_articles, article_metadata, file_metadata):
body = b'castle on a cloud'
file_id = file_metadata['id']
article_id = str(list_project_articles[0]['id'])
download_url = file_metadata['download_url']
article_metadata_url = project_provider.build_url('articles', article_id)
list_articles_url = project_provider.build_url('projects', project_provider.project_id, 'articles')
aiohttpretty.register_uri('GET', download_url, body=body, auto_length=True)
aiohttpretty.register_json_uri('GET', list_articles_url, body=list_project_articles)
aiohttpretty.register_json_uri('GET', article_metadata_url, body=article_metadata)
path = await project_provider.validate_path('/{}/{}'.format(article_id, file_id))
result = await project_provider.download(path)
content = await result.read()
assert content == body
3
Example 22
async def test_article_download(self, article_provider, article_metadata, file_metadata):
body = b'castle on a cloud'
file_id = file_metadata['id']
article_id = article_provider.article_id
article_metadata_url = article_provider.build_url('articles', article_id)
download_url = file_metadata['download_url']
aiohttpretty.register_uri('GET', download_url, body=body, auto_length=True)
aiohttpretty.register_json_uri('GET', article_metadata_url, body=article_metadata)
path = await article_provider.validate_path('/{}'.format(file_id))
result = await article_provider.download(path)
content = await result.read()
assert content == body
3
Example 23
async def test_download_accept_url(self, connected_provider):
body = b'dearly-beloved'
path = WaterButlerPath('/lets-go-crazy')
url = connected_provider.sign_url(path)
parsed_url = furl.furl(url)
parsed_url.args['filename'] = 'lets-go-crazy'
result = await connected_provider.download(path, accept_url=True)
assert result == parsed_url.url
aiohttpretty.register_uri('GET', url, body=body)
response = await aiohttp.request('GET', url)
content = await response.read()
assert content == body
3
Example 24
async def test_download_by_path(self, provider, repo_tree_metadata_root):
ref = hashlib.sha1().hexdigest()
file_sha = repo_tree_metadata_root['tree'][0]['sha']
path = await provider.validate_path('/file.txt')
url = provider.build_repo_url('git', 'blobs', file_sha)
tree_url = provider.build_repo_url('git', 'trees', ref, recursive=1)
latest_sha_url = provider.build_repo_url('git', 'refs', 'heads', path.identifier[0])
commit_url = provider.build_repo_url('commits', path=path.path.lstrip('/'), sha=path.identifier[0])
aiohttpretty.register_uri('GET', url, body=b'delicious')
aiohttpretty.register_json_uri('GET', tree_url, body=repo_tree_metadata_root)
aiohttpretty.register_json_uri('GET', commit_url, body=[{'commit': {'tree': {'sha': ref}}}])
result = await provider.download(path)
content = await result.read()
assert content == b'delicious'
3
Example 25
async def test_metadata_file_root_similar(self, connected_provider, file_root_similar):
path = WaterButlerPath('/similar')
url = connected_provider.build_url(path.path)
aiohttpretty.register_uri('HEAD', url, status=200, headers=file_root_similar)
result = await connected_provider.metadata(path)
assert result.name == 'similar'
assert result.path == '/similar'
assert result.kind == 'file'
3
Example 26
async def test_upload_create_nested(self, provider, file_stream):
upload_id = '7'
item = fixtures.list_file['items'][0]
path = WaterButlerPath(
'/ed/sullivan/show.mp3',
_ids=[str(x) for x in range(3)]
)
start_upload_url = provider._build_upload_url('files', uploadType='resumable')
finish_upload_url = provider._build_upload_url('files', uploadType='resumable', upload_id=upload_id)
aiohttpretty.register_uri('POST', start_upload_url, headers={'LOCATION': 'http://waterbutler.io?upload_id={}'.format(upload_id)})
aiohttpretty.register_json_uri('PUT', finish_upload_url, body=item)
result, created = await provider.upload(file_stream, path)
assert aiohttpretty.has_call(method='POST', uri=start_upload_url)
assert aiohttpretty.has_call(method='PUT', uri=finish_upload_url)
assert created is True
expected = GoogleDriveFileMetadata(item, path)
assert result == expected
3
Example 27
async def test_download_by_path_revision(self, provider, repo_tree_metadata_root):
ref = hashlib.sha1().hexdigest()
file_sha = repo_tree_metadata_root['tree'][0]['sha']
path = await provider.validate_path('/file.txt', branch='other_branch')
url = provider.build_repo_url('git', 'blobs', file_sha)
tree_url = provider.build_repo_url('git', 'trees', ref, recursive=1)
commit_url = provider.build_repo_url('commits', path=path.path.lstrip('/'), sha='Just a test')
aiohttpretty.register_uri('GET', url, body=b'delicious')
aiohttpretty.register_json_uri('GET', tree_url, body=repo_tree_metadata_root)
aiohttpretty.register_json_uri('GET', commit_url, body=[{'commit': {'tree': {'sha': ref}}}])
result = await provider.download(path, revision='Just a test')
content = await result.read()
assert content == b'delicious'
3
Example 28
async def test_metadata_file_does_not_exist(self, connected_provider):
path = WaterButlerPath('/does_not.exist')
url = connected_provider.build_url(path.path)
aiohttpretty.register_uri('HEAD', url, status=404)
with pytest.raises(exceptions.MetadataError):
await connected_provider.metadata(path)
3
Example 29
Project: waterbutler
License: View license
Source File: test_provider.py
Function: test_delete_folder
License: View license
Source File: test_provider.py
Function: test_delete_folder
async def test_delete_folder(self, provider):
item = fixtures.folder_metadata
del_url = provider.build_url('files', item['id'])
del_url_body = dumps({'labels': {'trashed': 'true'}})
path = WaterButlerPath('/foobar/', _ids=('doesntmatter', item['id']))
aiohttpretty.register_uri('PUT',
del_url,
body=del_url_body,
status=200)
result = await provider.delete(path)
assert aiohttpretty.has_call(method='PUT', uri=del_url)
3
Example 30
async def test_delete(self, connected_provider):
path = WaterButlerPath('/delete.file')
url = connected_provider.build_url(path.path)
aiohttpretty.register_uri('DELETE', url, status=204)
await connected_provider.delete(path)
assert aiohttpretty.has_call(method='DELETE', uri=url)
3
Example 31
Project: waterbutler
License: View license
Source File: test_provider.py
Function: test_validate_v1_path_file
License: View license
Source File: test_provider.py
Function: test_validate_v1_path_file
async def test_validate_v1_path_file(self, provider, file_metadata):
path = WaterButlerPath('/triangles.txt', prepend=provider.folder)
url = provider._webdav_url_ + path.full_path
aiohttpretty.register_uri('PROPFIND', url, body=file_metadata, auto_length=True, status=207)
try:
wb_path_v1 = await provider.validate_v1_path('/triangles.txt')
except Exception as exc:
pytest.fail(str(exc))
wb_path_v0 = await provider.validate_path('/triangles.txt')
assert wb_path_v1 == wb_path_v0
3
Example 32
async def test_download(self, provider, native_dataset_metadata):
path = '/21'
url = provider.build_url(dvs.DOWN_BASE_URL, path, key=provider.token)
draft_url = provider.build_url(dvs.JSON_BASE_URL.format(provider._id, 'latest'), key=provider.token)
published_url = provider.build_url(dvs.JSON_BASE_URL.format(provider._id, 'latest-published'), key=provider.token)
aiohttpretty.register_uri('GET', url, body=b'better', auto_length=True)
aiohttpretty.register_json_uri('GET', draft_url, status=200, body=native_dataset_metadata)
aiohttpretty.register_json_uri('GET', published_url, status=200, body=native_dataset_metadata)
path = await provider.validate_path(path)
result = await provider.download(path)
content = await result.read()
assert content == b'better'
3
Example 33
async def test_download(self, provider, file_metadata, file_like):
path = WaterButlerPath('/triangles.txt', prepend=provider.folder)
url = provider._webdav_url_ + path.full_path
aiohttpretty.register_uri('PROPFIND', url, body=file_metadata, auto_length=True, status=207)
aiohttpretty.register_uri('GET', url, body=b'squares', auto_length=True, status=200)
result = await provider.download(path)
content = await result.response.read()
assert content == b'squares'
3
Example 34
@pytest.fixture
def mock_temp_key(endpoint, temp_url_key):
aiohttpretty.register_uri(
'HEAD',
endpoint,
status=204,
headers={'X-Account-Meta-Temp-URL-Key': temp_url_key},
)
3
Example 35
async def test_delete(self, provider, file_metadata):
path = WaterButlerPath('/phile', prepend=provider.folder)
url = provider._webdav_url_ + path.full_path
aiohttpretty.register_uri('PROPFIND', url, body=file_metadata, auto_length=True, status=207)
path = await provider.validate_path('/phile')
url = provider._webdav_url_ + path.full_path
aiohttpretty.register_uri('DELETE', url, status=204)
await provider.delete(path)
3
Example 36
async def test_download(self, provider):
path = WaterButlerPath('/triangles.txt', prepend=provider.folder)
url = provider._build_content_url('files', 'auto', path.full_path)
aiohttpretty.register_uri('GET', url, body=b'better', auto_length=True)
result = await provider.download(path)
content = await result.response.read()
assert content == b'better'
3
Example 37
async def test_region_host(self, auth, credentials, settings, region_name, host, mock_time):
provider = S3Provider(auth, credentials, settings)
orig_host = provider.connection.host
region_url = provider.bucket.generate_url(
100,
'GET',
query_parameters={'location': ''},
)
aiohttpretty.register_uri('GET', region_url, status=200, body=location_response(region_name))
await provider._check_region()
assert provider.connection.host == host
3
Example 38
async def test_metadata_folder_root_level1(self, connected_provider, folder_root_level1):
path = WaterButlerPath('/level1/')
body = json.dumps(folder_root_level1).encode('utf-8')
url = connected_provider.build_url('', prefix=path.path, delimiter='/')
aiohttpretty.register_uri('GET', url, status=200, body=body)
result = await connected_provider.metadata(path)
assert len(result) == 1
assert result[0].name == 'level2'
assert result[0].path == '/level1/level2/'
assert result[0].kind == 'folder'
3
Example 39
async def test_download_version(self, provider, mock_time):
path = WaterButlerPath('/muhtriangle')
url = provider.bucket.new_key(path.path).generate_url(
100,
query_parameters={'versionId': 'someversion'},
response_headers={'response-content-disposition': 'attachment'},
)
aiohttpretty.register_uri('GET', url, body=b'delicious', auto_length=True)
result = await provider.download(path, version='someversion')
content = await result.read()
assert content == b'delicious'
3
Example 40
async def test_upload(self, provider, file_metadata, file_stream, settings):
path = await provider.validate_path('/phile')
metadata_url = provider.build_url('metadata', 'auto', path.full_path)
url = provider._build_content_url('files_put', 'auto', path.full_path)
aiohttpretty.register_uri('GET', metadata_url, status=404)
aiohttpretty.register_json_uri('PUT', url, status=200, body=file_metadata)
metadata, created = await provider.upload(file_stream, path)
expected = DropboxFileMetadata(file_metadata, provider.folder)
assert created is True
assert metadata == expected
assert aiohttpretty.has_call(method='PUT', uri=url)
3
Example 41
Project: waterbutler
License: View license
Source File: test_provider.py
Function: test_download_not_found
License: View license
Source File: test_provider.py
Function: test_download_not_found
async def test_download_not_found(self, provider, mock_time):
path = WaterButlerPath('/muhtriangle')
url = provider.bucket.new_key(path.path).generate_url(100, response_headers={'response-content-disposition': 'attachment'})
aiohttpretty.register_uri('GET', url, status=404)
with pytest.raises(exceptions.DownloadError):
await provider.download(path)
3
Example 42
async def test_delete_file(self, provider, file_metadata):
item = file_metadata['entries'][0]
path = WaterButlerPath('/{}'.format(item['name']), _ids=(provider.folder, item['id']))
url = provider.build_url('files', path.identifier)
aiohttpretty.register_uri('DELETE', url, status=204)
await provider.delete(path)
assert aiohttpretty.has_call(method='DELETE', uri=url)
3
Example 43
async def test_delete(self, provider, mock_time):
path = WaterButlerPath('/some-file')
url = provider.bucket.new_key(path.path).generate_url(100, 'DELETE')
aiohttpretty.register_uri('DELETE', url, status=200)
await provider.delete(path)
assert aiohttpretty.has_call(method='DELETE', uri=url)
3
Example 44
Project: waterbutler
License: View license
Source File: test_provider.py
Function: test_metadata_missing
License: View license
Source File: test_provider.py
Function: test_metadata_missing
async def test_metadata_missing(self, provider):
path = WaterButlerPath('/pfile', prepend=provider.folder)
url = provider.build_url('metadata', 'auto', path.full_path)
aiohttpretty.register_uri('GET', url, status=404)
with pytest.raises(exceptions.MetadataError):
await provider.metadata(path)
3
Example 45
async def test_metadata_file_root_level1_level2_file2_txt(self, connected_provider, file_root_level1_level2_file2_txt):
path = WaterButlerPath('/level1/level2/file2.txt')
url = connected_provider.build_url(path.path)
aiohttpretty.register_uri('HEAD', url, status=200, headers=file_root_level1_level2_file2_txt)
result = await connected_provider.metadata(path)
assert result.name == 'file2.txt'
assert result.path == '/level1/level2/file2.txt'
assert result.kind == 'file'
assert result.content_type == 'text/plain'
3
Example 46
Project: waterbutler
License: View license
Source File: test_provider.py
Function: test_download_not_found
License: View license
Source File: test_provider.py
Function: test_download_not_found
async def test_download_not_found(self, provider, file_metadata):
item = file_metadata['entries'][0]
path = WaterButlerPath('/vectors.txt', _ids=(provider.folder, None))
metadata_url = provider.build_url('files', item['id'])
aiohttpretty.register_uri('GET', metadata_url, status=404)
with pytest.raises(exceptions.DownloadError) as e:
await provider.download(path)
assert e.value.code == 404
3
Example 47
Project: waterbutler
License: View license
Source File: test_provider.py
Function: test_delete_folder
License: View license
Source File: test_provider.py
Function: test_delete_folder
async def test_delete_folder(self, provider, folder_object_metadata):
item = folder_object_metadata
path = WaterButlerPath('/{}/'.format(item['name']), _ids=(provider.folder, item['id']))
url = provider.build_url('folders', path.identifier, recursive=True)
aiohttpretty.register_uri('DELETE', url, status=204)
await provider.delete(path)
assert aiohttpretty.has_call(method='DELETE', uri=url)
3
Example 48
Project: waterbutler
License: View license
Source File: test_provider.py
Function: test_download_not_found
License: View license
Source File: test_provider.py
Function: test_download_not_found
async def test_download_not_found(self, connected_provider):
path = WaterButlerPath('/lets-go-crazy')
url = connected_provider.sign_url(path)
aiohttpretty.register_uri('GET', url, status=404)
with pytest.raises(exceptions.DownloadError):
await connected_provider.download(path)
3
Example 49
async def test_metadata_file_root_similar_name(self, connected_provider, file_root_similar_name):
path = WaterButlerPath('/similar.file')
url = connected_provider.build_url(path.path)
aiohttpretty.register_uri('HEAD', url, status=200, headers=file_root_similar_name)
result = await connected_provider.metadata(path)
assert result.name == 'similar.file'
assert result.path == '/similar.file'
assert result.kind == 'file'
3
Example 50
async def test_errors_out(self, provider, repo_metadata):
path = await provider.validate_path('/Imarealboy/')
url = provider.build_repo_url('contents', path.child('.gitkeep').path)
aiohttpretty.register_uri('PUT', url, status=400)
with pytest.raises(exceptions.CreateFolderError) as e:
await provider.create_folder(path)
assert e.value.code == 400