-
Notifications
You must be signed in to change notification settings - Fork 123
Closed
Description
In the documentation for STACObject.get_self_href
, it states that the returned HREF will be absolute:
Lines 145 to 164 in 76ef6a3
def get_self_href(self) -> Optional[str]: | |
"""Gets the absolute HREF that is represented by the ``rel == 'self'`` | |
:class:`~pystac.Link`. | |
Returns: | |
str or None: The absolute HREF of this object, or ``None`` if | |
there is no self link defined. | |
Note: | |
A self link can exist for objects, even if the link is not read or | |
written to the JSON-serialized version of the object. Any object | |
read from :func:`STACObject.from_file <pystac.STACObject.from_file>` will | |
have the HREF the file was read from set as it's self HREF. All self | |
links have absolute (as opposed to relative) HREFs. | |
""" | |
self_link = self.get_single_link(pystac.RelType.SELF) | |
if self_link and self_link.has_target_href(): | |
return self_link.get_target_str() | |
else: | |
return None |
However, no work is done to ensure that the self href is absolute, as demonstrated by this failing test:
def test_relative_self_href(self) -> None:
self.item.add_link(pystac.Link("self", "a/relative/path/item.json"))
# this fails
self.assertEqual(
self.item.get_self_href(), os.path.abspath("a/relative/path/item.json")
)
This is true for objects read via, e.g. pystac.read_file
as well. Should the returned self HREF be resolved to an absolute HREF as best as possible, or should we just return None
?
Metadata
Metadata
Assignees
Labels
No labels