diff --git a/CHANGELOG.md b/CHANGELOG.md index 742ac45c..2358c648 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,12 +11,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Make `get_collection` raise if `collection_id` is empty ([#809](https://github.com/stac-utils/pystac-client/pull/809)) +### Added + +- Add comprehensive test coverage for ConformanceClasses enum ([#834](https://github.com/stac-utils/pystac-client/pull/834)) + ### Documentation - Update contributing guide to consistently use `uv` workflow ([#822](https://github.com/stac-utils/pystac-client/pull/822)) - Fix format script to use `ruff-format` instead of deprecated `black` hook ([#822](https://github.com/stac-utils/pystac-client/pull/822)) - Add "How to..." section to usage documentation with latest datetime search across multiple collections example ([#823](https://github.com/stac-utils/pystac-client/pull/823)) + ## [v0.9.0] - 2025-07-17 ### Added diff --git a/tests/test_conformance.py b/tests/test_conformance.py new file mode 100644 index 00000000..d2dc873d --- /dev/null +++ b/tests/test_conformance.py @@ -0,0 +1,32 @@ +import pytest + +from pystac_client.conformance import ConformanceClasses + + +class TestConformanceClasses: + def test_get_by_name_raises_for_invalid_names(self) -> None: + """Test get_by_name raises ValueError for invalid conformance class names.""" + with pytest.raises(ValueError, match="Invalid conformance class 'invalid'"): + ConformanceClasses.get_by_name("invalid") + + with pytest.raises(ValueError, match="Invalid conformance class 'nonexistent'"): + ConformanceClasses.get_by_name("nonexistent") + + with pytest.raises(ValueError, match="Invalid conformance class ''"): + ConformanceClasses.get_by_name("") + + def test_get_by_name_valid(self) -> None: + """Test get_by_name with valid conformance class names.""" + assert ConformanceClasses.get_by_name("core") == ConformanceClasses.CORE + assert ConformanceClasses.get_by_name("CORE") == ConformanceClasses.CORE + + def test_valid_uri_property(self) -> None: + """Test valid_uri property returns correct URI pattern.""" + assert ( + ConformanceClasses.CORE.valid_uri == "https://api.stacspec.org/v1.0.*/core" + ) + + def test_pattern_property(self) -> None: + """Test pattern property returns compiled regex.""" + core_pattern = ConformanceClasses.CORE.pattern + assert core_pattern.match("https://api.stacspec.org/v1.0.0/core")