mirror of https://github.com/ecmwf/eccodes.git
Make test robust to new keys
This commit is contained in:
parent
a79e5cf2e5
commit
d063285b70
|
@ -26,6 +26,115 @@ for i1 in range(len(TEST_KEYS)):
|
|||
SELECTION_DICTIONARY[TEST_KEYS[i1]] = TEST_VALUES[i1]
|
||||
TEST_INDEX_OUTPUT = TESTGRIB
|
||||
TEST_STEPRANGE = ('0', '12', '18', '24', '6')
|
||||
# These keys should be available even if new keys become available
|
||||
KNOWN_GRIB_KEYS = ['globalDomain', 'GRIBEditionNumber',
|
||||
'tablesVersionLatest', 'grib2divider', 'angularPrecision',
|
||||
'missingValue', 'ieeeFloats', 'isHindcast',
|
||||
'section0Length', 'identifier', 'discipline',
|
||||
'editionNumber', 'totalLength', 'sectionNumber',
|
||||
'section1Length', 'numberOfSection', 'centre',
|
||||
'centreDescription', 'subCentre', 'tablesVersion',
|
||||
'masterDir', 'localTablesVersion', 'localDir',
|
||||
'significanceOfReferenceTime', 'year', 'month', 'day',
|
||||
'hour', 'minute', 'second', 'dataDate', 'julianDay',
|
||||
'dataTime', 'productionStatusOfProcessedData',
|
||||
'typeOfProcessedData', 'md5Section1',
|
||||
'selectStepTemplateInterval', 'selectStepTemplateInstant',
|
||||
'stepType', 'setCalendarId', 'deleteCalendarId',
|
||||
'is_uerra', 'sectionNumber', 'grib2LocalSectionPresent',
|
||||
'section2Length', 'numberOfSection', 'addEmptySection2',
|
||||
'grib2LocalSectionNumber', 'marsClass', 'marsType',
|
||||
'marsStream', 'experimentVersionNumber', 'class', 'type',
|
||||
'stream', 'productDefinitionTemplateNumberInternal',
|
||||
'localDefinitionNumber', 'eps', 'oceanAtmosphereCoupling',
|
||||
'legBaseDate', 'legBaseTime', 'legNumber',
|
||||
'referenceDate', 'climateDateFrom', 'climateDateTo',
|
||||
'addExtraLocalSection', 'deleteExtraLocalSection',
|
||||
'extraLocalSectionPresent', 'section2Padding',
|
||||
'sectionNumber', 'gridDescriptionSectionPresent',
|
||||
'section3Length', 'numberOfSection',
|
||||
'sourceOfGridDefinition', 'numberOfDataPoints',
|
||||
'numberOfOctectsForNumberOfPoints',
|
||||
'interpretationOfNumberOfPoints', 'PLPresent',
|
||||
'gridDefinitionTemplateNumber',
|
||||
'gridDefinitionDescription', 'shapeOfTheEarth',
|
||||
'scaleFactorOfRadiusOfSphericalEarth',
|
||||
'scaledValueOfRadiusOfSphericalEarth',
|
||||
'scaleFactorOfEarthMajorAxis',
|
||||
'scaledValueOfEarthMajorAxis',
|
||||
'scaleFactorOfEarthMinorAxis',
|
||||
'scaledValueOfEarthMinorAxis', 'radius', 'Ni', 'Nj',
|
||||
'basicAngleOfTheInitialProductionDomain', 'mBasicAngle',
|
||||
'angleMultiplier', 'mAngleMultiplier',
|
||||
'subdivisionsOfBasicAngle', 'angleDivisor',
|
||||
'latitudeOfFirstGridPoint', 'longitudeOfFirstGridPoint',
|
||||
'resolutionAndComponentFlags',
|
||||
'resolutionAndComponentFlags1',
|
||||
'resolutionAndComponentFlags2',
|
||||
'iDirectionIncrementGiven', 'jDirectionIncrementGiven',
|
||||
'uvRelativeToGrid', 'resolutionAndComponentFlags6',
|
||||
'resolutionAndComponentFlags7',
|
||||
'resolutionAndComponentFlags8',
|
||||
'ijDirectionIncrementGiven', 'latitudeOfLastGridPoint',
|
||||
'longitudeOfLastGridPoint', 'iDirectionIncrement', 'N',
|
||||
'scanningMode', 'iScansNegatively', 'jScansPositively',
|
||||
'jPointsAreConsecutive', 'alternativeRowScanning',
|
||||
'iScansPositively', 'scanningMode5', 'scanningMode6',
|
||||
'scanningMode7', 'scanningMode8', 'g2grid',
|
||||
'latitudeOfFirstGridPointInDegrees',
|
||||
'longitudeOfFirstGridPointInDegrees',
|
||||
'latitudeOfLastGridPointInDegrees',
|
||||
'longitudeOfLastGridPointInDegrees',
|
||||
'iDirectionIncrementInDegrees', 'global', 'latLonValues',
|
||||
'latitudes', 'longitudes', 'distinctLatitudes',
|
||||
'distinctLongitudes', 'isOctahedral', 'gaussianGridName',
|
||||
'section3Padding', 'gridType', 'md5Section3',
|
||||
'sectionNumber', 'section4Length', 'numberOfSection',
|
||||
'NV', 'neitherPresent', 'productDefinitionTemplateNumber',
|
||||
'genVertHeightCoords', 'Parameter information',
|
||||
'parameterCategory', 'parameterNumber', 'parameterUnits',
|
||||
'parameterName', 'typeOfGeneratingProcess',
|
||||
'backgroundProcess', 'generatingProcessIdentifier',
|
||||
'hoursAfterDataCutoff', 'minutesAfterDataCutoff',
|
||||
'indicatorOfUnitOfTimeRange', 'x', 'stepUnits',
|
||||
'forecastTime', 'startStep', 'endStep', 'stepRange',
|
||||
'stepTypeInternal', 'validityDate', 'validityTime',
|
||||
'typeOfFirstFixedSurface', 'unitsOfFirstFixedSurface',
|
||||
'nameOfFirstFixedSurface',
|
||||
'scaleFactorOfFirstFixedSurface',
|
||||
'scaledValueOfFirstFixedSurface',
|
||||
'typeOfSecondFixedSurface', 'unitsOfSecondFixedSurface',
|
||||
'nameOfSecondFixedSurface',
|
||||
'scaleFactorOfSecondFixedSurface',
|
||||
'scaledValueOfSecondFixedSurface', 'pressureUnits',
|
||||
'typeOfLevel', 'level', 'bottomLevel', 'topLevel',
|
||||
'tempPressureUnits', 'EPS information',
|
||||
'typeOfEnsembleForecast', 'perturbationNumber',
|
||||
'numberOfForecastsInEnsemble', 'x', 'paramIdECMF',
|
||||
'paramId', 'shortNameECMF', 'shortName', 'unitsECMF',
|
||||
'units', 'nameECMF', 'name', 'cfNameECMF', 'cfName',
|
||||
'cfVarNameECMF', 'cfVarName', 'modelName', 'ifsParam',
|
||||
'PVPresent', 'deletePV', 'md5Section4', 'lengthOfHeaders',
|
||||
'md5Headers', 'sectionNumber',
|
||||
'grib 2 Section 5 DATA REPRESENTATION SECTION',
|
||||
'section5Length', 'numberOfSection', 'numberOfValues',
|
||||
'dataRepresentationTemplateNumber', 'packingType',
|
||||
'referenceValue', 'referenceValueError',
|
||||
'binaryScaleFactor', 'decimalScaleFactor',
|
||||
'optimizeScaleFactor', 'bitsPerValue',
|
||||
'typeOfOriginalFieldValues', 'md5Section5',
|
||||
'sectionNumber', 'grib 2 Section 6 BIT-MAP SECTION',
|
||||
'section6Length', 'numberOfSection', 'bitMapIndicator',
|
||||
'bitmapPresent', 'md5Section6', 'sectionNumber',
|
||||
'grib 2 Section 7 data', 'section7Length',
|
||||
'numberOfSection', 'codedValues', 'values',
|
||||
'packingError', 'unpackedError', 'maximum', 'minimum',
|
||||
'average', 'numberOfMissing', 'standardDeviation',
|
||||
'skewness', 'kurtosis', 'isConstant',
|
||||
'changeDecimalPrecision', 'decimalPrecision',
|
||||
'setBitsPerValue', 'getNumberOfValues', 'scaleValuesBy',
|
||||
'offsetValuesBy', 'productType', 'md5Section7',
|
||||
'section8Length', '7777']
|
||||
|
||||
|
||||
class TestGribFile(unittest.TestCase):
|
||||
|
@ -76,10 +185,10 @@ class TestGribMessage(unittest.TestCase):
|
|||
"""Metadata is read correctly from GribMessage."""
|
||||
with GribFile(TESTGRIB) as grib:
|
||||
msg = GribMessage(grib)
|
||||
key_count = 253
|
||||
self.assertEqual(len(msg), key_count)
|
||||
for key in KNOWN_GRIB_KEYS:
|
||||
assert key in msg.keys()
|
||||
self.assertEqual(msg.size(), 160219)
|
||||
self.assertEqual(len(msg.keys()), key_count)
|
||||
self.assertEqual(len(msg.keys()), len(msg))
|
||||
|
||||
def test_missing_message_behavior(self):
|
||||
"""Missing messages are detected properly."""
|
||||
|
|
Loading…
Reference in New Issue