Skip to content

Commit

Permalink
Improve coverage for scientific, version exts
Browse files Browse the repository at this point in the history
  • Loading branch information
duckontheweb committed Jun 17, 2021
1 parent b83338d commit 5f2296f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tests/extensions/test_datacube.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import json
import unittest
import pystac
from pystac.extensions.datacube import DatacubeExtension

from tests.utils import TestCases, assert_to_from_dict
from tests.utils import TestCases


class DatacubeTest(unittest.TestCase):
def setUp(self) -> None:
self.maxDiff = None
self.example_uri = TestCases.get_path(
"data-files/datacube/item.json"
)

self.example_uri = TestCases.get_path("data-files/datacube/item.json")

def test_validate_datacube(self) -> None:
item = pystac.Item.from_file(self.example_uri)
item.validate()
Expand Down Expand Up @@ -52,4 +49,4 @@ def test_asset_ext_add_to(self) -> None:

_ = DatacubeExtension.ext(asset, add_if_missing=True)

self.assertIn(DatacubeExtension.get_schema_uri(), item.stac_extensions)
self.assertIn(DatacubeExtension.get_schema_uri(), item.stac_extensions)
11 changes: 11 additions & 0 deletions tests/extensions/test_scientific.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,17 @@ def test_extension_not_implemented(self) -> None:
with self.assertRaises(pystac.ExtensionNotImplemented):
_ = ScientificExtension.ext(collection)

def test_ext_add_to(self) -> None:
collection = pystac.Collection.from_file(self.example_collection_uri)
collection.stac_extensions.remove(ScientificExtension.get_schema_uri())
self.assertNotIn(
ScientificExtension.get_schema_uri(), collection.stac_extensions
)

_ = ScientificExtension.ext(collection, add_if_missing=True)

self.assertIn(ScientificExtension.get_schema_uri(), collection.stac_extensions)


class SummariesScientificTest(unittest.TestCase):
def setUp(self) -> None:
Expand Down
9 changes: 9 additions & 0 deletions tests/extensions/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,15 @@ def test_extension_not_implemented(self) -> None:
with self.assertRaises(pystac.ExtensionNotImplemented):
_ = VersionExtension.ext(collection)

def test_ext_add_to(self) -> None:
collection = pystac.Collection.from_file(self.example_collection_uri)
collection.stac_extensions.remove(VersionExtension.get_schema_uri())
self.assertNotIn(VersionExtension.get_schema_uri(), collection.stac_extensions)

_ = VersionExtension.ext(collection, add_if_missing=True)

self.assertIn(VersionExtension.get_schema_uri(), collection.stac_extensions)


if __name__ == "__main__":
unittest.main()

0 comments on commit 5f2296f

Please sign in to comment.