Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/providers/osfstorage/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ def folder_children_metadata():
with open(os.path.join(os.path.dirname(__file__), 'fixtures/root_provider.json')) as fp:
return json.load(fp)['folder_children_metadata']

@pytest.fixture
def folder_children_metadata_minimal():
with open(os.path.join(os.path.dirname(__file__), 'fixtures/root_provider.json')) as fp:
return json.load(fp)['folder_children_metadata_minimal']


@pytest.fixture
def download_response():
Expand Down
26 changes: 26 additions & 0 deletions tests/providers/osfstorage/fixtures/root_provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,32 @@
"latestVersionSeen": null
}
],
"folder_children_metadata_minimal": [
{
"id": "59c0054cb7d1c90114c456af",
"kind": "folder",
"name": "New Folder",
"path": "/59c0054cb7d1c90114c456af/"
},
{
"id": "59a9b637b7d1c903ab5a8f58",
"kind": "file",
"name": "one",
"path": "/59a9b637b7d1c903ab5a8f58"
},
{
"id": "59a9b628b7d1c903ab5a8f52",
"kind": "file",
"name": "doc.rst",
"path": "/59a9b628b7d1c903ab5a8f52"
},
{
"id": "59a5adb9b7d1c901cd40f0e9",
"kind": "file",
"name": "video.mp4",
"path": "/59a5adb9b7d1c901cd40f0e9"
}
],
"file_metadata": {
"checkout": null,
"contentType": null,
Expand Down
32 changes: 25 additions & 7 deletions tests/providers/osfstorage/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
file_lineage, file_metadata,
file_metadata_object, file_path,
folder_lineage, folder_metadata,
folder_children_metadata, folder_path,
folder_children_metadata, folder_children_metadata_minimal, folder_path,
revisions_metadata, revision_metadata_object,
download_response, download_path,
upload_response, upload_path, root_path,
Expand Down Expand Up @@ -210,7 +210,7 @@ async def test_delete_folder_contents(self, provider_one, file_path, folder_path

children_url, params = build_signed_url_without_auth(provider_one, 'GET',
folder_path.identifier, 'children',
user_id=provider_one.auth['id'])
user_id=provider_one.auth['id'], minimal=False)
aiohttpretty.register_json_uri('GET', children_url, params=params, status=200,
body=folder_children_metadata)

Expand All @@ -227,7 +227,7 @@ class TestMetadata:
async def test_provider_metadata_empty(self, provider_one, folder_path, mock_time):

url, params = build_signed_url_without_auth(provider_one, 'GET', folder_path.identifier,
'children', user_id=provider_one.auth['id'])
'children', user_id=provider_one.auth['id'], minimal=False)
aiohttpretty.register_json_uri('GET', url, params=params, status_code=200, body=[])

res = await provider_one.metadata(folder_path)
Expand All @@ -241,7 +241,7 @@ async def test_provider_metadata_folder(self, provider_one, folder_path,
folder_children_metadata, mock_time):

url, params = build_signed_url_without_auth(provider_one, 'GET', folder_path.identifier,
'children', user_id=provider_one.auth['id'])
'children', user_id=provider_one.auth['id'], minimal=False)
aiohttpretty.register_json_uri('GET', url, params=params, status=200,
body=folder_children_metadata)

Expand Down Expand Up @@ -276,7 +276,7 @@ async def test_provider_metadata_without_id(self, provider_one, folder_path,
folder_children_metadata, mock_time):

url, params = build_signed_url_without_auth(provider_one, 'GET', folder_path.identifier,
'children')
'children', minimal=False)
aiohttpretty.register_json_uri('GET', url, params=params, status=200,
body=folder_children_metadata)
folder_path._parts[-1]._id = None
Expand Down Expand Up @@ -732,7 +732,7 @@ async def test_validate_path_404s(self, provider_one, file_lineage, mock_time):
async def test_revalidate_path_new(self, provider_one, folder_path, folder_children_metadata,
mock_time):
url, params = build_signed_url_without_auth(provider_one, 'GET', folder_path.identifier,
'children', user_id=provider_one.auth['id'])
'children', user_id=provider_one.auth['id'], minimal=False)
aiohttpretty.register_json_uri('GET', url, params=params, status=200,
body=folder_children_metadata)

Expand All @@ -745,7 +745,7 @@ async def test_revalidate_path_new(self, provider_one, folder_path, folder_child
async def test_revalidate_path_existing(self, provider_one, folder_path,
folder_children_metadata, mock_time):
url, params = build_signed_url_without_auth(provider_one, 'GET', folder_path.identifier,
'children', user_id=provider_one.auth['id'])
'children', user_id=provider_one.auth['id'], minimal=False)
aiohttpretty.register_json_uri('GET', url, params=params, status=200,
body=folder_children_metadata)

Expand Down Expand Up @@ -1253,3 +1253,21 @@ async def test_intra_copy_reject_by_quota(self, provider_one, auth, credentials,
src_provider.can_intra_copy.assert_called_once_with(dst_provider, src_path)
src_provider.intra_copy.assert_not_called()
src_provider.download.assert_not_called()

class TestMinimalMetadataDAZ:

@pytest.mark.asyncio
@pytest.mark.aiohttpretty
async def test_minimal_metadata(self, provider_one, folder_path, folder_children_metadata_minimal):

url, params = build_signed_url_without_auth(provider_one, 'GET', folder_path.identifier,
'children', user_id=provider_one.auth['id'], minimal=True)
aiohttpretty.register_json_uri('GET', url, params=params, status=200,
body=folder_children_metadata_minimal)

metadata = await provider_one.metadata(folder_path, minimal=True)

assert [type(metadata_item) for metadata_item in metadata] == [OsfStorageFolderMetadata, OsfStorageFileMetadata, OsfStorageFileMetadata, OsfStorageFileMetadata]
assert [metadata_item.name for metadata_item in metadata] == ['New Folder', 'one', 'doc.rst', 'video.mp4']
assert [metadata_item.path for metadata_item in metadata] == ['/59c0054cb7d1c90114c456af/', '/59a9b637b7d1c903ab5a8f58', '/59a9b628b7d1c903ab5a8f52', '/59a5adb9b7d1c901cd40f0e9']
assert [metadata_item.provider for metadata_item in metadata] == ['osfstorage', 'osfstorage', 'osfstorage', 'osfstorage']
2 changes: 1 addition & 1 deletion waterbutler/providers/osfstorage/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ async def _item_metadata(self, path, revision=None):
async def _children_metadata(self, path, **kwargs):
resp = await self.make_signed_request(
'GET',
self.build_url(path.identifier, 'children', user_id=self.auth.get('id'), minimal=kwargs.get('minimal')),
self.build_url(path.identifier, 'children', user_id=self.auth.get('id'), minimal=kwargs.get('minimal', False)),
expects=(200, )
)
resp_json = await resp.json()
Expand Down
Loading