-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ditch redundant test code + clarify purpose. (#199)
* Ditch redundant test code + clarify purpose. * Some moves and renames.
- Loading branch information
Showing
3 changed files
with
43 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
iris_grib/tests/integration/iris_integration/test_callback.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright iris-grib contributors | ||
# | ||
# This file is part of iris-grib and is released under the LGPL license. | ||
# See COPYING and COPYING.LESSER in the root of the repository for full | ||
# licensing details. | ||
""" | ||
Test that iris load callbacks work with iris-grib. | ||
""" | ||
|
||
# Import iris_grib.tests first so that some things can be initialised before | ||
# importing anything else. | ||
import iris_grib.tests as tests | ||
|
||
|
||
import iris | ||
import iris.coords | ||
|
||
|
||
class TestCallbacks(tests.IrisGribTest): | ||
def test_load_callback(self): | ||
# What this actually tests: | ||
# 1. iris.load works with grib (though the GRIB picker is in Iris) | ||
# 2. callbacks work with the grib loader | ||
# 3. grib loaded result matches a cube snapshot | ||
def load_callback(cube, field, filename): | ||
# GRIB2 loader callback : 'field' is a GribMessage, which | ||
# has 'sections'. | ||
cube.add_aux_coord( | ||
iris.coords.AuxCoord( | ||
field.sections[1]["year"], | ||
long_name="extra_year_number_coord", | ||
units="no_unit", | ||
) | ||
) | ||
|
||
fname = tests.get_data_path(("GRIB", "global_t", "global.grib2")) | ||
cube = iris.load_cube(fname, callback=load_callback) | ||
self.assertCML(cube) | ||
|
||
|
||
if __name__ == "__main__": | ||
tests.main() |
File renamed without changes.