def testGt1416(self): app = Flask(__name__) api = Api(app) os.chdir('../') enablePlugin(api, 'testPlugin1') os.chdir('tst') self.assertTrue('resource_gt_1416' in api.endpoints)
def testLogWritingForPluginLoadFail(self): enablePlugin(api, PLUGIN_FAIL_PLUGIN) last_log_document = db[COLLECTION_LOG].find().sort( ID, pymongo.DESCENDING).limit(1) self.assertNotEqual( last_log_document[0][FIELD_MESSAGE].find(MESSAGE_LOAD_FAIL), -1) self.assertEqual(last_log_document[0][FIELD_USERID], ANONYM_USER)
def testIsPluginEnabled(self): os.chdir('../') enablePlugin(api, TEST_PLUGIN_NAME) os.chdir(TEST_PATH) RESULT = isPluginEnabled(TEST_PLUGIN_NAME, app) self.assertTrue(RESULT is True) RESULT = isPluginEnabled(TEST_PLUGIN_NAME_NOT_VALID, app) self.assertTrue(RESULT is False)
def get(self): pluginsDict = dict((key, request.args.get(key)) for key in request.args.keys()) for plugin in pluginsDict: setPluginState(plugin, pluginsDict[plugin]) if pluginsDict[plugin].lower() == u'true' and isPluginEnabled( plugin, getApp()) == False: dirs = os.walk("plugins").next() if plugin not in dirs[1]: raise PluginDoesNotExistException(plugin) else: enablePlugin(getApi(), plugin)
def initApp(api): homeDir = os.getcwd() if homeDir.find('/var/www') != -1: homeDir = '/var/www/geomongo/' os.chdir(homeDir) else: if homeDir.find('src/tst') != -1: os.chdir('..') pluginList = getPluginList() for pluginName in pluginList: if getPluginState(pluginName) is True and \ checkConfigPlugin(pluginName) is True: enablePlugin(api, pluginName) os.chdir(homeDir)