diff --git a/pywps/inout/basic.py b/pywps/inout/basic.py index c4a7470fb..02f54c478 100644 --- a/pywps/inout/basic.py +++ b/pywps/inout/basic.py @@ -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 diff --git a/pywps/inout/storage/file.py b/pywps/inout/storage/file.py index e1fbf8a35..77e0081ce 100644 --- a/pywps/inout/storage/file.py +++ b/pywps/inout/storage/file.py @@ -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) @@ -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 diff --git a/tests/test_filestorage.py b/tests/test_filestorage.py index 1433e1b86..6c768f246 100644 --- a/tests/test_filestorage.py +++ b/tests/test_filestorage.py @@ -15,6 +15,7 @@ import unittest + class FileStorageTests(unittest.TestCase): def setUp(self): @@ -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) @@ -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() @@ -88,4 +88,4 @@ def load_tests(loader=None, tests=None, pattern=None): suite_list = [ loader.loadTestsFromTestCase(FileStorageTests) ] - return unittest.TestSuite(suite_list) \ No newline at end of file + return unittest.TestSuite(suite_list)