def testCreateFromAlwaysHandleConfig(self): """Test that creating with always_handle works as intended.""" config = forgiving_config_parser.ForgivingConfigParser() section = base_event.SectionName(build_event.NewBuild.KEYWORD) config.add_section(section) config.set(section, 'always_handle', 'True') self.mox.ReplayAll() event = build_event.NewBuild.CreateFromConfig(config, self.mv) self.assertTrue(event.ShouldHandle())
def testCreateFromAlwaysHandleConfig(self): """Test that creating with always_handle works as intended.""" config = forgiving_config_parser.ForgivingConfigParser() section = base_event.SectionName(timed_event.Nightly.KEYWORD) config.add_section(section) config.set(section, 'always_handle', 'True') timed_event.TimedEvent._now().MultipleTimes().AndReturn( self.BaseTime()) self.mox.ReplayAll() event = timed_event.Nightly.CreateFromConfig(config, self.mv) self.assertTrue(event.ShouldHandle())
def testCreateFromConfig(self): """Test that creating from config is equivalent to using constructor.""" config = forgiving_config_parser.ForgivingConfigParser() section = base_event.SectionName(timed_event.Weekly.KEYWORD) config.add_section(section) config.set(section, 'hour', '%d' % self._HOUR) timed_event.TimedEvent._now().MultipleTimes().AndReturn( self.BaseTime()) self.mox.ReplayAll() self.assertEquals(self.CreateEvent(), timed_event.Weekly.CreateFromConfig(config, self.mv))
def _ParseConfig(cls, config): """Create args to pass to __init__ by parsing |config|. Calls super class' _ParseConfig() method, then parses these additonal options: hour: Integer hour, on a 24 hour clock. """ from_base = super(Weekly, cls)._ParseConfig(config) section = base_event.SectionName(cls.KEYWORD) event_time = config.getint(section, 'hour') or cls._DEFAULT_HOUR from_base.update({'event_time': event_time}) return from_base