def test_get_calendars(self): registry = IsoRegistry(load_standard_modules=False) registry.register('RE', self.region) registry.register('RE-SR', self.subregion) registry.register('OR-SR', self.subregion) calendars = registry.get_calendars(['RE'], include_subregions=True) self.assertEqual(2, len(calendars)) self.assertIn('RE', calendars) self.assertIn('RE-SR', calendars) calendars = registry.get_calendars(['RE'], include_subregions=False) self.assertEqual(1, len(calendars)) self.assertIn('RE', calendars)
def test_get_calendars_empty_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) # Empty arg, no subregions calendars = registry.get_calendars([], include_subregions=False) self.assertEqual(len(calendars), 3) self.assertEqual(set({"RE", "RE2", "RE3"}), set(calendars.keys())) # Empty arg, with subregions calendars = registry.get_calendars([], include_subregions=True) self.assertEqual(len(calendars), 4) self.assertEqual(set({"RE", "RE2", "RE3", "RE-SR"}), set(calendars.keys()))
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()))
def test_get_calendars_unknown(self): registry = IsoRegistry(load_standard_modules=False) registry.register('RE', self.region) calendars = registry.get_calendars(['XX']) self.assertEqual(calendars, {})