Exemple #1
0
    def test_ext_add_to(self) -> None:
        item = pystac.Item.from_file(self.label_example_1_uri)
        item.stac_extensions.remove(LabelExtension.get_schema_uri())
        self.assertNotIn(LabelExtension.get_schema_uri(), item.stac_extensions)

        _ = LabelExtension.ext(item, add_if_missing=True)

        self.assertIn(LabelExtension.get_schema_uri(), item.stac_extensions)
Exemple #2
0
    def test_summaries_adds_uri(self) -> None:
        col = pystac.Collection.from_file(self.EXAMPLE_COLLECTION)
        col.stac_extensions = []
        self.assertRaisesRegex(
            pystac.ExtensionNotImplemented,
            r"Could not find extension schema URI.*",
            LabelExtension.summaries,
            col,
            False,
        )
        _ = LabelExtension.summaries(col, True)

        self.assertIn(LabelExtension.get_schema_uri(), col.stac_extensions)

        LabelExtension.remove_from(col)
        self.assertNotIn(LabelExtension.get_schema_uri(), col.stac_extensions)
Exemple #3
0
    def test_extension_not_implemented(self) -> None:
        # Should raise exception if Item does not include extension URI
        item = pystac.Item.from_file(self.label_example_1_uri)
        item.stac_extensions.remove(LabelExtension.get_schema_uri())

        with self.assertRaises(pystac.ExtensionNotImplemented):
            _ = LabelExtension.ext(item)