def test_override_config_with_env(self): """ Tests override_config_with_env(). """ config_parser = config.init_config(self.temp_config_file) config.set_default_config(config_parser, set_all=True) os.environ['HCBOT_HIPCHAT_JID'] = '123' config.override_config_with_env(config_parser) self.assertEqual(config_parser.get(u'hipchat', u'jid'), u'123', u"[hipchat][jid] mismatch") # test integer os.environ['HCBOT_HIPCHAT_STFU_MINUTES'] = u'2' config.override_config_with_env(config_parser) self.assertIs(config_parser.getint(u'hipchat', u'stfu_minutes'), 2, u"[hipchat][stfu_minutes] mismatch")
def test_set_default_all(self): """ Tests set_default_config() with set_all=True. """ # copy example-config.ini with open(os.path.join(BASE_DIR, u'data', u'example-config.ini'), 'rb') as ef: data = ef.read() with open(self.temp_config_file, 'wb') as f: f.write(data) config_parser = config.init_config(self.temp_config_file) config.set_default_config(config_parser, set_all=True) self.assertEqual(config_parser.get(u'team', u'topic_update_time'), u'0 9 * * MON-FRI *', u"[team][topic_update_time] mismatch") # test saving config.write_config_file_utf8(config_parser, self.temp_config_file) config_parser = config.init_config(self.temp_config_file) self.assertEqual(config_parser.get(u'team', u'topic_update_time'), u'0 9 * * MON-FRI *', u"[team][topic_update_time] mismatch")