def validate_item_link_type(href, link_type, should_include_self): item_dict = STAC_IO.read_json(href) item = STACObject.from_file(href) for link in item.get_links(): if not link.rel == 'self': self.assertEqual(link.link_type, link_type) rels = set([link['rel'] for link in item_dict['links']]) self.assertEqual('self' in rels, should_include_self)
def validate_catalog_link_type(href, link_type, should_include_self): cat_dict = STAC_IO.read_json(href) cat = STACObject.from_file(href) for link in cat.get_links(): if not link.rel == 'self': self.assertEqual(link.link_type, link_type) rels = set([link['rel'] for link in cat_dict['links']]) self.assertEqual('self' in rels, should_include_self) for child_link in cat.get_child_links(): child_href = make_absolute_href(child_link.target, href) validate_catalog_link_type(child_href, link_type, catalog_type == CatalogType.ABSOLUTE_PUBLISHED) for item_link in cat.get_item_links(): item_href = make_absolute_href(item_link.target, href) validate_item_link_type(item_href, link_type, catalog_type == CatalogType.ABSOLUTE_PUBLISHED)