diff --git a/spine_engine/project_item/project_item_resource.py b/spine_engine/project_item/project_item_resource.py index ed16933b..f2c60a37 100644 --- a/spine_engine/project_item/project_item_resource.py +++ b/spine_engine/project_item/project_item_resource.py @@ -159,13 +159,12 @@ def url(self): def url(self, url): self._url = url self._parsed_url = urlparse(self._url) - self._filepath = url2pathname(self._parsed_url.path) @property def path(self): """Returns the resource path in the local syntax, as obtained from parsing the url.""" if not self._filepath: - self._filepath = url2pathname(self._parsed_url.path) + self._filepath = url2pathname(self._parsed_url.path) if self._parsed_url.path else "" return self._filepath @property diff --git a/tests/project_item/test_project_item_resource.py b/tests/project_item/test_project_item_resource.py index cab9d64f..3e35d5b4 100644 --- a/tests/project_item/test_project_item_resource.py +++ b/tests/project_item/test_project_item_resource.py @@ -138,6 +138,17 @@ def test_schema_is_stored_in_metadata(self): resource = url_resource("project item", "sqlite:///path/do/db.sqlite", "my database", schema="my_schema") self.assertEqual(resource.metadata, {"schema": "my_schema"}) + def test_url_setter_works_when_url_is_set_to_none(self): + resource = url_resource("project item", "sqlite:///path/do/db.sqlite", "my database") + resource.url = None + self.assertIsNone(resource.url) + + +class TestTransientFileResource(unittest.TestCase): + def test_path_works_even_when_resource_has_no_url(self): + resource = transient_file_resource("Provider", "files@Provider") + self.assertEqual(resource.path, "") + class TestGetSource(unittest.TestCase): def test_file_resource(self):