예제 #1
0
    def test_registry02(self):
        "register() method"
        registry = DatePeriodRegistry()
        registry.register(DaysPeriod, WeeksPeriod)

        period = registry.get_period(DaysPeriod.name, 1)
        self.assertIsInstance(period, DaysPeriod)

        self.assertIsNone(registry.get_period(MinutesPeriod.name, 1))
예제 #2
0
    def test_registry01(self):
        "Register in __init__"
        registry = DatePeriodRegistry(MinutesPeriod, HoursPeriod)

        period1 = registry.get_period(MinutesPeriod.name, 1)
        self.assertIsInstance(period1, MinutesPeriod)

        period2 = registry.get_period(HoursPeriod.name, 1)
        self.assertIsInstance(period2, HoursPeriod)

        self.assertIsNone(registry.get_period('invalid', 1))