Skip to content
Open
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
2 changes: 2 additions & 0 deletions stor/dx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,8 @@ def canonical_resource(self):
if utils.has_trailing_slash(self):
raise ValueError('Invalid operation ({method}) on folder path ({path})'
.format(path=self, method=sys._getframe(2).f_code.co_name))
if utils.is_valid_dxid(self.resource, "file"):
return self.resource
objects = [{
'name': self.name,
'folder': ('/' + self.resource).parent,
Expand Down
14 changes: 14 additions & 0 deletions stor/tests/test_dx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1960,3 +1960,17 @@ def test_content_type(self, mock_stat):
self.assertEqual(DXPath('dx://P:/C/T').content_type, 'text/plain')
mock_stat.return_value = {}
self.assertEqual(DXPath('dx://P:/C/T').content_type, '')


class TestMixedPaths(DXTestCase):
def test_mixed_paths(self):
self.setup_temporary_project()
pth = stor.Path(f"dx://{self.project}:/mypath.txt")
with pth.open("w") as fp:
fp.write("sometext")
file_id = pth.canonical_path.name
project_id = pth.canonical_path.project

assert stor.Path(f"dx://{project_id}:/{pth.name}").canonical_path == pth.canonical_path
assert stor.Path(f"dx://{project_id}:/{file_id}").canonical_path == pth.canonical_path
assert stor.Path(f"dx://{pth.project}:/{file_id}").canonical_path == pth.canonical_path