def test_boolean_setting_type(self): Registry.add_instance("setting_service", MockSettingService()) setting = BooleanSettingType() setting.set_value("true") self.assertTrue(setting.get_value()) setting.set_value(True) self.assertTrue(setting.get_value()) setting.set_value("false") self.assertFalse(setting.get_value()) setting.set_value(False) self.assertFalse(setting.get_value()) self.assertRaises(Exception, lambda: setting.set_value("test"))
def instance(cls, name=None, override=False): instance_name = name if name else cls.__name__ Registry.add_instance(instance_name, cls(), override) return cls
print( 'You can manually create a config by editing the template /conf/config.template.json and rename it to config.json' ) exit(0) logger.debug("Reading config file '%s'" % config_file) with open(config_file) as cfg: config = json.load(cfg) logger.debug("Loading instances") Registry.load_instances([ "core", os.path.join("modules", "core"), os.path.join("modules", "addons") ]) Registry.add_instance("mmdb_parser", MMDBParser("text.mdb")) Registry.inject_all() bot = Registry.get_instance("mangopie") db = Registry.get_instance("db") db.connect(config["db_host"], config["db_name"]) bot.init(config, Registry) if int(config["dimension"]) == 1: bot.connect("chat.d1.funcom.com", 7105) elif int(config["dimension"]) == 2: bot.connect("chat.dt.funcom.com", 7109) elif int(config["dimension"]) == 3: bot.connect("localhost", 9993) else: print('Invalid server!')
def instance(cls, name=None): instance_name = name if name else cls.__name__ Registry.add_instance(instance_name, cls()) return cls