def test_news(self): call_function = None plugin_handler.load('core/plugins', db) for i in plugin_handler.plugin_subscriptions: if i['name'] == "news": call_function = i["function"] print (call_function({"command": "Read me the news", "username": "******", "db": db}))
def initialize(db): """ Run the plugin loader :param db: """ log.info("Loading plugins") plugin_handler.load("core/plugins", db)
def test_weather(self): call_function = None plugin_handler.load('core/plugins', db) for i in plugin_handler.plugin_subscriptions: if i['name'] == "weather": call_function = i["function"] response = call_function({"command": "Tell me the weather", "username": "******", "db": db}) logging.info("Weather response is {0}".format(response)) print (response)
def test_search(self): call_function = None plugin_handler.load('core/plugins', db) for i in plugin_handler.plugin_subscriptions: if i['name'] == "search": call_function = i["function"] searches = [ "Who is the queen of england?", "How old is putin?", "When did napoleon die?", "Who invented python?", "what day is it", "what's 27 times 62", "When did bach die?", "Who is will beddow?", "Who's obama?" ] def do_search(query, call_function): print (plugin_handler.subscriptions().call_plugin(call_function, { "command": query, "db": db, "user_table":db['users'].find_one(username="******")})) map(lambda x: do_search(x, call_function), searches)
def test_subscriptions(self): plugin_handler.load('core/plugins', db) plugin_num = 5 print plugin_handler.plugin_subscriptions self.assertEqual(len(plugin_handler.plugin_subscriptions), plugin_num)