예제 #1
0
    def test_no_stac_core_conformance(self):
        """Should raise a ConformanceError if the API does not conform to the STAC API - Core spec."""
        api_content = read_data_file('astraea_api.json', parse_json=True)

        # Remove "conformsTo" attribute
        api_content['conformsTo'] = []

        with pytest.raises(ConformanceError):
            Client.from_dict(api_content)
예제 #2
0
    def test_no_conformance(self):
        """Should raise a KeyError if no conformance info can be found. Luckily, the test API doesn't publish
        a "conformance" link so we can just remove the "conformsTo" attribute to test this."""
        api_content = read_data_file('astraea_api.json', parse_json=True)

        # Remove "conformsTo" attribute
        del api_content['conformsTo']

        with pytest.raises(KeyError):
            Client.from_dict(api_content)
예제 #3
0
    def test_spec_conformance(self):
        """Testing conformance against a ConformanceClass should allow APIs using legacy URIs to pass."""
        api_content = read_data_file('astraea_api.json', parse_json=True)

        # Set conformsTo URIs to conform with STAC API - Core using official URI
        api_content['conformsTo'] = [
            'https://api.stacspec.org/v1.0.0-beta.1/core'
        ]
        api = Client.from_dict(api_content)

        # Must have a conformance property that is the list of URIs from the conformsTo property
        assert hasattr(api, 'conformance')
        assert api.conformance == api_content['conformsTo']

        # Check the conformance to STAC API - Core using the ConformanceClass
        assert api.conforms_to(ConformanceClasses.STAC_API_CORE)

        # ... and using a URI string
        assert api.conforms_to('https://api.stacspec.org/v1.0.0-beta.1/core')
예제 #4
0
    def test_legacy_conformance(self):
        """APIs publishing legacy conformance URIs should pass when tested against a ConformanceClass, but
        fail when tested against the official URI string"""
        api_content = read_data_file('astraea_api.json', parse_json=True)

        # Set conformsTo URIs to conform with STAC API - Core using official URI
        api_content['conformsTo'] = [
            'http://stacspec.org/spec/api/1.0.0-beta.1/core'
        ]
        api = Client.from_dict(api_content)

        # Must have a conformance property that is the list of URIs from the conformsTo property
        assert hasattr(api, 'conformance')
        assert api.conformance == api_content['conformsTo']

        assert api.conforms_to(ConformanceClasses.STAC_API_CORE)

        assert not api.conforms_to(
            'https://api.stacspec.org/v1.0.0-beta.1/core')
 def astraea_api(self):
     api_content = read_data_file('astraea_api.json', parse_json=True)
     return Client.from_dict(api_content)