Skip to content

Commit 88c6bf6

Browse files
authored
Merge pull request #148 from nansencenter/otc2025
Update for the OTC 2025
2 parents 071f0b6 + 775e905 commit 88c6bf6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

metanorm/normalizers/geospaas/earthdata_cmr.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ def get_instrument(self, raw_metadata):
8282
"""Only get the first instrument from the raw metadata, because
8383
GeoSPaaS does not support more than one instrument per dataset
8484
"""
85-
return utils.get_gcmd_instrument(
86-
raw_metadata['umm']['Platforms'][0]['Instruments'][0]['ShortName'])
85+
try:
86+
return utils.get_gcmd_instrument(
87+
raw_metadata['umm']['Platforms'][0]['Instruments'][0]['ShortName'])
88+
except KeyError:
89+
return utils.get_gcmd_instrument(utils.UNKNOWN)
8790

8891
@utils.raises((KeyError, IndexError))
8992
def get_location_geometry(self, raw_metadata):

tests/normalizers/test_earthdata_cmr.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,10 @@ def test_instrument(self):
246246
mock_get_gcmd_method.assert_called_with('VIIRS')
247247

248248
def test_instrument_missing_attribute(self):
249-
"""A MetadataNormalizationError must be raised if the raw
250-
attribute is missing
249+
"""An unknown instrument must be returned if the raw attribute
250+
is missing
251251
"""
252-
with self.assertRaises(MetadataNormalizationError):
253-
self.normalizer.get_instrument({})
254-
with self.assertRaises(MetadataNormalizationError):
255-
self.normalizer.get_instrument({'umm': {'foo': 'bar'}})
252+
self.assertEqual(self.normalizer.get_instrument({})['Category'], 'Unknown')
256253

257254
def test_location_geometry_one_bounding_box(self):
258255
"""Test getting the location_geometry from one bounding box"""

0 commit comments

Comments
 (0)