|
1 | 1 | """Tests for the ACDD metadata normalizer"""
|
2 | 2 | import unittest
|
3 | 3 | import unittest.mock as mock
|
| 4 | +from collections import OrderedDict |
4 | 5 | from datetime import datetime
|
5 | 6 |
|
6 | 7 | from dateutil.tz import tzutc
|
@@ -38,6 +39,11 @@ def test_entry_id(self):
|
38 | 39 | }
|
39 | 40 | self.assertEqual(self.normalizer.get_entry_id(attributes), 'V2020245000600.L2_SNPP_OC')
|
40 | 41 |
|
| 42 | + def test_entry_id_from_granuleUR(self): |
| 43 | + """Test getting the ID from the GranuleUR field""" |
| 44 | + attributes = {'umm': {'GranuleUR': 'foo'}} |
| 45 | + self.assertEqual(self.normalizer.get_entry_id(attributes), 'foo') |
| 46 | + |
41 | 47 | def test_entry_id_missing_attribute(self):
|
42 | 48 | """A MetadataNormalizationError must be raised if the raw
|
43 | 49 | attribute is missing
|
@@ -109,6 +115,27 @@ def test_summary(self):
|
109 | 115 | 'Description: Platform=SUOMI-NPP, ' +
|
110 | 116 | 'Instrument=VIIRS, Start date=2020-09-01T00:06:00Z')
|
111 | 117 |
|
| 118 | + def test_summary_no_platform(self): |
| 119 | + """Test getting a summary when no platform info is available |
| 120 | + """ |
| 121 | + attributes = { |
| 122 | + "umm": { |
| 123 | + "TemporalExtent": { |
| 124 | + "RangeDateTime": { |
| 125 | + "BeginningDateTime": "2020-09-01T00:06:00Z", |
| 126 | + "EndingDateTime": "2020-09-01T00:11:59Z" |
| 127 | + } |
| 128 | + }, |
| 129 | + "CollectionReference": { |
| 130 | + "ShortName": "VIIRSN_L2_OC", |
| 131 | + "Version": "2018" |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + self.assertEqual( |
| 136 | + self.normalizer.get_summary(attributes), |
| 137 | + 'Description: Start date=2020-09-01T00:06:00Z;Processing level: 2') |
| 138 | + |
112 | 139 | def test_summary_missing_attribute(self):
|
113 | 140 | """A MetadataNormalizationError must be raised if the raw
|
114 | 141 | attribute is missing
|
@@ -189,10 +216,15 @@ def test_platform_missing_attribute(self):
|
189 | 216 | """A MetadataNormalizationError must be raised if the raw
|
190 | 217 | attribute is missing
|
191 | 218 | """
|
192 |
| - with self.assertRaises(MetadataNormalizationError): |
193 |
| - self.normalizer.get_platform({}) |
194 |
| - with self.assertRaises(MetadataNormalizationError): |
195 |
| - self.normalizer.get_platform({'umm': {'foo': 'bar'}}) |
| 219 | + unknown_platform = OrderedDict([ |
| 220 | + ('Category', 'Unknown'), |
| 221 | + ('Series_Entity', 'Unknown'), |
| 222 | + ('Short_Name', 'Unknown'), |
| 223 | + ('Long_Name', 'Unknown') |
| 224 | + ]) |
| 225 | + self.assertDictEqual(self.normalizer.get_platform({}), unknown_platform) |
| 226 | + self.assertDictEqual(self.normalizer.get_platform({'umm': {'foo': 'bar'}}), |
| 227 | + unknown_platform) |
196 | 228 |
|
197 | 229 | def test_instrument(self):
|
198 | 230 | """Test getting the instrument"""
|
|
0 commit comments