Skip to content

Commit

Permalink
fix file storage (#504)
Browse files Browse the repository at this point in the history
* fix file storage
  • Loading branch information
cehbrecht committed Dec 9, 2019
1 parent a0ff367 commit 9709866
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion pywps/inout/basic.py
Expand Up @@ -965,7 +965,9 @@ def storage(self, storage):
def get_url(self):
"""Return URL pointing to data
"""
url = self.storage.url(self)
# TODO: it is not obvious that storing happens here
(_, _, url) = self.storage.store(self)
# url = self.storage.url(self)
return url


Expand Down
4 changes: 2 additions & 2 deletions pywps/inout/storage/file.py
Expand Up @@ -108,7 +108,7 @@ def _do_store(self, output):

just_file_name = os.path.basename(output_name)

url = self.url(urljoin(str(request_uuid), just_file_name))
url = self.url("{}/{}".format(request_uuid, just_file_name))
LOGGER.info('File output URI: {}'.format(url))

return (STORE_TYPE.PATH, output_name, url)
Expand All @@ -131,7 +131,7 @@ def url(self, destination):
if isinstance(destination, IOHandler):
output_name, _ = _build_output_name(destination)
just_file_name = os.path.basename(output_name)
dst = urljoin(str(destination.uuid), just_file_name)
dst = "{}/{}".format(destination.uuid, just_file_name)
else:
dst = destination

Expand Down
8 changes: 4 additions & 4 deletions tests/test_filestorage.py
Expand Up @@ -15,6 +15,7 @@

import unittest


class FileStorageTests(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -42,7 +43,6 @@ def test_store(self):
with open(self.tmp_dir + '/' + store_str) as f:
self.assertEqual(f.read(), "Hello World!")


def test_write(self):
configuration.CONFIG.set('server', 'outputpath', self.tmp_dir)
configuration.CONFIG.set('server', 'outputurl', 'file://' + self.tmp_dir)
Expand All @@ -61,16 +61,16 @@ def test_url(self):
storage = FileStorageBuilder().build()
output = ComplexOutput('testme', 'Test', supported_formats=[FORMATS.TEXT], workdir=self.tmp_dir)
output.data = "Hello World!"
output.uuid = '595129f0-1a6c-11ea-a30c-acde48001122'
url = storage.url(output)

self.assertEqual('file://' + self.tmp_dir + '/input.txt', url)
self.assertEqual('file://' + self.tmp_dir + '/595129f0-1a6c-11ea-a30c-acde48001122' + '/input.txt', url)

file_name = 'test.txt'
url = storage.url(file_name)

self.assertEqual('file://' + self.tmp_dir + '/test.txt', url)


def test_location(self):
configuration.CONFIG.set('server', 'outputpath', self.tmp_dir)
storage = FileStorageBuilder().build()
Expand All @@ -88,4 +88,4 @@ def load_tests(loader=None, tests=None, pattern=None):
suite_list = [
loader.loadTestsFromTestCase(FileStorageTests)
]
return unittest.TestSuite(suite_list)
return unittest.TestSuite(suite_list)

0 comments on commit 9709866

Please sign in to comment.