def test_get_items(self): registry = IsoRegistry(load_standard_modules=False) registry.register('RE', self.region) registry.register('RE-SR', self.subregion) registry.register('OR-SR', self.subregion) items = registry.items(['RE'], include_subregions=True) self.assertEqual(2, len(items)) self.assertIn('RE', items) self.assertIn('RE-SR', items) items = registry.items(['RE'], include_subregions=False) self.assertEqual(1, len(items)) self.assertIn('RE', items)
def test_items_deprecation(self): registry = IsoRegistry(load_standard_modules=False) with warnings.catch_warnings(record=True) as w: # Cause all warnings to always be triggered. warnings.simplefilter("always") # Trigger a warning. registry.items() # Verify some things self.assertEqual(len(w), 1) warning = w[0] self.assertTrue(issubclass(warning.category, DeprecationWarning)) self.assertIn("deprecated", str(warning.message))
def test_get_items(self): registry = IsoRegistry() registry.register('RE', self.region) registry.register('RE-SR', self.subregion) registry.register('OR-SR', self.subregion) items = registry.items(['RE'], include_subregions=True) self.assertEqual(2, len(items)) self.assertIn('RE', items) self.assertIn('RE-SR', items) items = registry.items(['RE'], include_subregions=False) self.assertEqual(1, len(items)) self.assertIn('RE', items)
def test_get_calendars_no_arg(self): registry = IsoRegistry(load_standard_modules=False) # 3 regions, one sub-region registry.register('RE', self.region) registry.register('RE2', self.region) registry.register('RE3', self.region) registry.register('RE-SR', self.subregion) # Should be equivalent to [] + no subregions calendars = registry.get_calendars() self.assertEqual(len(calendars), 3) self.assertEqual(set({"RE", "RE2", "RE3"}), set(calendars.keys())) # Should be equivalent to [] + include subregions calendars = registry.items(include_subregions=True) self.assertEqual(len(calendars), 4) self.assertEqual(set({"RE", "RE2", "RE3", "RE-SR"}), set(calendars.keys()))