def test_loads_defaults(self, get_appsettings): """Test that defaults are loaded.""" c = config._FmnConfig() c.load_config({}) self.assertEqual(c['fmn.autocreate'], False)
def setUp(self): super(FMNConsumerTests, self).setUp() self.config = config._FmnConfig() self.config['fmn.sqlalchemy.uri'] = 'sqlite://' self.config['fmn.consumer.enabled'] = True self.config['validate_signatures'] = False self.hub = mock.Mock(config=self.config)
def test_with_settings(self, fedmsg_load): """Test with the optional settings parameter.""" c = config._FmnConfig() c.load_config({'fmn.irc.nickserv_pass': '******'}) self.assertEqual(c['fmn.irc.nickserv_pass'], 'hunter2') self.assertEqual(fedmsg_load.call_count, 0)
def test_marks_loaded(self, fedmsg_load): c = config._FmnConfig() fedmsg_load.return_value = {'fmn.irc.nickserv_pass': '******'} c.load_config() fedmsg_load.assert_called_once_with() self.assertTrue(('fmn.irc.nickserv_pass', 'hunter2') in c.items()) self.assertTrue(c.loaded)
def test_validates(self, get_appsettings): """Test that the config is validated.""" c = config._FmnConfig() with self.assertRaises(ValueError) as exc: c.load_config({'fmn.junk_suffixes': 'notalist'}) self.assertEqual(str(exc.exception), ( 'Invalid config values were set: \n\tfmn.junk_suffixes: "notalist"' ' is not "<type \'list\'>"'))
def setUp(self): self.config = config._FmnConfig() self.config.load_config = mock.Mock() self.config['fmn.irc.nickserv_pass'] = '******'