def test_folder_json_api_serialize(self): folder_metadata = utils.MockFolderMetadata() serialized = folder_metadata.json_api_serialized('n0d3z') link_suffix = '/v1/resources/n0d3z/providers/mock/Bar/' etag = hashlib.sha256('{}::{}'.format( 'mock', 'etag').encode('utf-8')).hexdigest() assert serialized['id'] == 'mock/Bar/' assert serialized['type'] == 'files' assert serialized['attributes'] == { 'extra': {}, 'kind': 'folder', 'name': 'Bar', 'path': '/Bar/', 'provider': 'mock', 'materialized': '/Bar/', 'etag': etag, 'size': None, } assert serialized['links']['new_folder'].endswith(link_suffix + '?kind=folder') assert serialized['links']['move'].endswith(link_suffix) assert serialized['links']['upload'].endswith(link_suffix + '?kind=folder') assert 'download' not in serialized['links'] assert serialized['links']['delete'].endswith(link_suffix)
def test_get_not_coro(self): expected = [utils.MockFileMetadata(), utils.MockFolderMetadata()] self.mock_provider.revisions = mock.Mock(return_value=expected) resp = yield self.http_client.fetch( self.get_url('/revisions?provider=queenhub&path=/brian.tiff'), ) assert { 'data': [m.serialized() for m in expected] } == json.loads(resp.body.decode())
def test_create_folder(self): self.mock_provider.create_folder = utils.MockCoroutine( return_value=utils.MockFolderMetadata()) resp = yield self.http_client.fetch( self.get_url('/file?provider=queenhub&path=/folder/'), method='POST', body='') calls = self.mock_provider.create_folder.call_args_list assert len(calls) == 1 args, kwargs = calls[0] assert kwargs.get('action') == 'create_folder' assert resp.code == 201
def test_folder_json_api_serialize(self): folder_metadata = utils.MockFolderMetadata() folder_metadata.children = [utils.MockFileMetadata()] serialized = folder_metadata.json_api_serialized('n0d3z') child = serialized['attributes']['children'][0] etag = hashlib.sha256('{}::{}'.format( 'mock', 'etag').encode('utf-8')).hexdigest() assert len(serialized['attributes']['children']) == 1 assert child == { 'extra': {}, 'kind': 'file', 'name': 'Foo.name', 'path': '/Foo.name', 'provider': 'mock', 'materialized': '/Foo.name', 'etag': etag, 'contentType': 'application/octet-stream', 'modified': 'never', 'size': 1337, }
def test_folder_metadata(self): folder_metadata = utils.MockFolderMetadata() assert folder_metadata.is_folder == True assert folder_metadata.is_file == False
def test_folder_metadata(self): folder_metadata = utils.MockFolderMetadata() assert folder_metadata.is_file is False assert folder_metadata.is_folder is True