File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
metanorm/normalizers/geospaas Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff 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 ):
Original file line number Diff line number Diff 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"""
You can’t perform that action at this time.
0 commit comments