diff --git a/controllers/default.py b/controllers/default.py index b4e587bd2d..3d0b278152 100755 --- a/controllers/default.py +++ b/controllers/default.py @@ -1203,9 +1203,10 @@ def audit(): return s3_rest_controller("s3", "audit") def edentest(): - + """ + Special function to respond to get requests made by EdenTest + """ arg = request.args(0) - print request.args if arg == "deployment_settings": asked = request.args[1:] @@ -1215,12 +1216,16 @@ def edentest(): func_name = "get_" + setting function = getattr(settings, func_name) # eg value of function - settings.get_template() - value = function() + try: + value = function() + except TypeError: + continue + return_settings[setting] = value return response.json(return_settings) - return response.json() + return response.json({}) # END ========================================================================= diff --git a/tests/execution/libs/edentest_robot.py b/tests/execution/libs/edentest_robot.py index f538b5dbf4..ebb3302d28 100644 --- a/tests/execution/libs/edentest_robot.py +++ b/tests/execution/libs/edentest_robot.py @@ -1,57 +1,41 @@ # -*- coding: utf-8 -*- -from robot.libraries.OperatingSystem import OperatingSystem import ast from robot.api import logger -import os +import requests class edentest_robot: - def __init__(self, web2py, eden_path): - logger.debug("Got arguments %s %s" % (web2py, eden_path), html=True) - self.web2py = web2py - self.eden_path = eden_path + def __init__(self, server, appname): + """ + Initialize the class variables + """ + logger.debug("Arguments %s %s" % (server, appname), html=True) + + self.base_url = "http://" + server + "/" + appname def get_deployment_settings(self, *asked): """ - Takes the required settings as arguments eg: Template Base Public Url - Returns a list of values if len(list) > 1 else returns the first value as a - string. - Raises a warning if a setting is not found. + Returns the deployment settings asked in a dict where key is the + asked setting. It makes a get request to eden/default/edentest + and uses s3cfg to get the settings. + It uses env. proxy settings """ - self._setcwd() - - logger.info("Getting values for - %s" % " ".join(asked), html=True) - cmd = "python " + self.web2py + " --no-banner -S eden -M -R " + self.eden_path +"/tests/execution/libs/eden_interface.py -A -S" + logger.console("base_url %s" % (self.base_url)) + request_url = self.base_url + "/default/edentest/deployment_settings" for key in asked: - cmd = cmd + " " + key - - rc, output = OperatingSystem().run_and_return_rc_and_output(cmd) - - logger.debug("Return code for the cmd %s is %d" % (cmd, rc)) - logger.info("Returned Settings %s" % output) - - self._resetcwd() + request_url += "/" + key + logger.console("request_url %s" % (request_url)) - output = ast.literal_eval(output) + response = requests.get(request_url) + if response.status_code != requests.codes.ok: + logger.warn("Could not contact the Eden server") + return {} + output = response.json() for key in asked: - if key not in output.keys(): + if key not in output: logger.warn("Could not fetch the setting %s" % key) return output - - def _setcwd(self): - """ - Sets the CWD to the root of eden - """ - self._oldcwd = os.getcwd() - self._newcwd = self._oldcwd.split("/eden/")[0] + "/eden/" - os.chdir(self._newcwd) - - def _resetcwd(self): - """ - Resets the CWD to the directory from which tests were run - """ - os.chdir(self._oldcwd) diff --git a/tests/implementation/resources/main.txt b/tests/implementation/resources/main.txt index f052f5ee71..2f5ecc7d9c 100644 --- a/tests/implementation/resources/main.txt +++ b/tests/implementation/resources/main.txt @@ -1,10 +1,9 @@ *** Settings *** Documentation Main resource file for Eden Tests Library Selenium2Library -Library HttpLibrary.HTTP Library Collections Variables ../../execution/settings/config.py -Library ../../execution/libs/edentest_robot.py ${WEB2PY} ${EDEN_PATH} +Library ../../execution/libs/edentest_robot.py ${SERVER} ${APPNAME} Resource auth.txt Resource base.txt Resource crud.txt