Skip to content

Commit d76e0f9

Browse files
committed
point unit tests at schemas in fork of stac-spec
1 parent bc4439e commit d76e0f9

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

tests/test_eo.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import json
22
import os
33
import unittest
4+
from jsonschema import ValidationError
45

56
from pystac import *
67
from pystac.eo import (Band, EOAsset, EOItem, band_desc, band_range, eo_key)
7-
from tests.utils import (TestCases, test_to_from_dict)
8+
from tests.utils import (SchemaValidator, TestCases, test_to_from_dict)
89

910

1011
class EOItemTest(unittest.TestCase):
@@ -79,6 +80,14 @@ def test_add_eo_fields_to_dict(self):
7980
self.eo_dict['properties']).items() if k.startswith('eo:')}
8081
self.assertDictEqual(d, comp_d)
8182

83+
def test_validate_eo(self):
84+
sv = SchemaValidator()
85+
self.assertIsNone(sv.validate_dict(self.eo_dict, EOItem))
86+
87+
with open(self.URI_2) as f:
88+
eo_dict_2 = json.load(f)
89+
with self.assertRaises(ValidationError):
90+
sv.validate_dict(eo_dict_2, EOItem)
8291

8392
class EOAssetTest(unittest.TestCase):
8493
def setUp(self):

tests/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,17 @@ def test_case_3():
122122
class SchemaValidator:
123123
REPO = 'https://raw.githubusercontent.com/radiantearth/stac-spec'
124124
TAG = 'v{}'.format(STAC_VERSION)
125-
SCHEMA_BASE_URI = '{}/{}'.format(REPO, TAG)
126-
125+
# SCHEMA_BASE_URI = '{}/{}'.format(REPO, TAG)
126+
# Temporarily set to point to a fork if stac-spec with updated
127+
# schemas for Label and EO
128+
SCHEMA_BASE_URI = 'https://raw.githubusercontent.com/simonkassel/stac-spec/sk/refactor-extension-schemas'
129+
127130
schemas = {
128131
Catalog: 'catalog-spec/json-schema/catalog.json',
129132
Collection: 'collection-spec/json-schema/collection.json',
130133
Item: 'item-spec/json-schema/item.json',
131-
LabelItem: 'extensions/label/schema.json',
134+
LabelItem: 'extensions/label/json-schema/stac-label-item-schema.json',
135+
EOItem: 'extensions/eo/json-schema/stac-extension-eo.json'
132136
}
133137

134138
for c in schemas:

0 commit comments

Comments
 (0)