def test_valid(self): global_attributes = {'Conventions': 'CF-1.5', 'comment': 'Mocked test object'} engine = self._make_engine(global_attributes) build_cube_metadata(engine) expected = global_attributes self.assertEqual(engine.cube.attributes, expected)
def test_valid(self): global_attributes = { 'Conventions': 'CF-1.5', 'comment': 'Mocked test object' } engine = _make_engine(global_attributes) build_cube_metadata(engine) expected = global_attributes self.assertEqual(engine.cube.attributes, expected)
def check_cube_names(self, inputs, expected): # Inputs - attributes on the fake CF Variable. standard_name, long_name = inputs # Expected - The expected cube attributes. exp_standard_name, exp_long_name = expected engine = _make_engine(standard_name=standard_name, long_name=long_name) build_cube_metadata(engine) # Check the cube's standard name and long name are as expected. self.assertEqual(engine.cube.standard_name, exp_standard_name) self.assertEqual(engine.cube.long_name, exp_long_name)
def test_invalid(self): global_attributes = {"Conventions": "CF-1.5", "comment": "Mocked test object", "calendar": "standard"} engine = self._make_engine(global_attributes) with mock.patch("warnings.warn") as warn: build_cube_metadata(engine) # Check for a warning. self.assertEqual(warn.call_count, 1) self.assertIn("Skipping global attribute 'calendar'", warn.call_args[0][0]) # Check resulting attributes. The invalid entry 'calendar' # should be filtered out. global_attributes.pop("calendar") expected = global_attributes self.assertEqual(engine.cube.attributes, expected)
def test_invalid(self): global_attributes = { 'Conventions': 'CF-1.5', 'comment': 'Mocked test object', 'calendar': 'standard' } engine = _make_engine(global_attributes) with mock.patch('warnings.warn') as warn: build_cube_metadata(engine) # Check for a warning. self.assertEqual(warn.call_count, 1) self.assertIn("Skipping global attribute 'calendar'", warn.call_args[0][0]) # Check resulting attributes. The invalid entry 'calendar' # should be filtered out. global_attributes.pop('calendar') expected = global_attributes self.assertEqual(engine.cube.attributes, expected)
def test_valid(self): global_attributes = {"Conventions": "CF-1.5", "comment": "Mocked test object"} engine = self._make_engine(global_attributes) build_cube_metadata(engine) expected = global_attributes self.assertEqual(engine.cube.attributes, expected)