def test_register_and_start_instance(self): """ Test whether the weblab instance can be started successfully. PRERREQUISITE: weblabstarter script needs to be running in the background. """ time.sleep(2) settings = prepare_system( "*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings ) self._settings = settings base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL]) creation_results = create_weblab_environment(base_url, settings) configure_web_server(creation_results) register_and_start_instance("*****@*****.**", {}) start_port, end_port = creation_results["start_port"], creation_results["end_port"]
def test_finish_deployment(self): """ test_finish_deployment: Tests that every step can be done, and the deployment finished. PRERREQUISITES: apache-reloader and weblab-starter scripts running. """ settings = prepare_system( "*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings ) self._settings = settings base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL]) creation_results = create_weblab_environment(base_url, settings) configure_web_server(creation_results) register_and_start_instance("*****@*****.**", self.wcloud_settings) start_port, end_port = creation_results["start_port"], creation_results["end_port"] finish_deployment("*****@*****.**", settings, start_port, end_port, self.wcloud_settings) pass
def test_register_and_start_instance(self): """ Test whether the weblab instance can be started successfully. PRERREQUISITE: weblabstarter script needs to be running in the background. """ time.sleep(2) settings = prepare_system("*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings) self._settings = settings base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL]) creation_results = create_weblab_environment(base_url, settings) configure_web_server(creation_results) register_and_start_instance("*****@*****.**", {}) start_port, end_port = creation_results[ "start_port"], creation_results["end_port"]
def test_configure_web_server(self): """ Checks whether the Apache server can be configured correctly. PRERREQUISITE: Apache Reloader script must previously be running. """ settings = prepare_system( "*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings ) self._settings = settings base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL]) creation_results = create_weblab_environment(base_url, settings) configure_web_server(creation_results) assert os.path.isfile(os.path.join(base_url, "../", "apache.conf")) content = open(os.path.join(base_url, "../", "apache.conf"), "r").read() assert "testentity" in content lines = content.split("\n") line = [line.strip() for line in lines if "testentity" in line][0] assert os.path.isfile(line.split('"')[1])
def test_finish_deployment_thorough(self): """ test_finish_deployment_thorough: Tests that every step can be done, and the deployment finished. Checks that after being configured, Apache is indeed serving the new instance correctly. PRERREQUISITES: apache-reloader and weblab-starter scripts running; apache2 configured correctly to load the instances. """ settings = prepare_system("*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings) self._settings = settings base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL]) creation_results = create_weblab_environment(base_url, settings) configure_web_server(creation_results) register_and_start_instance("*****@*****.**", self.wcloud_settings) start_port, end_port = creation_results[ "start_port"], creation_results["end_port"] finish_deployment("*****@*****.**", settings, start_port, end_port, self.wcloud_settings) # Check that the new instance is being served correctly. bot = requests.Session() r = bot.get("http://localhost/testentity/weblab/client/index.html") text = r.text print text assert "weblabclientlab" in text assert "input" in text assert "hiddenPassword" in text # Check that we can login with admin/password. r = bot.post( "http://localhost/testentity/weblab/login/json/", data= """{"params":{"username":"******", "password":"******"}, "method":"login"}""" ) str = r.text print "The request returned: " + str j = json.loads(str) assert not j["is_exception"] assert "id" in j["result"]
def test_configure_web_server(self): """ Checks whether the Apache server can be configured correctly. PRERREQUISITE: Apache Reloader script must previously be running. """ settings = prepare_system("*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings) self._settings = settings base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL]) creation_results = create_weblab_environment(base_url, settings) configure_web_server(creation_results) assert os.path.isfile(os.path.join(base_url, "../", "apache.conf")) content = open(os.path.join(base_url, "../", "apache.conf"), "r").read() assert "testentity" in content lines = content.split("\n") line = [line.strip() for line in lines if "testentity" in line][0] assert os.path.isfile(line.split("\"")[1])
def test_finish_deployment(self): """ test_finish_deployment: Tests that every step can be done, and the deployment finished. PRERREQUISITES: apache-reloader and weblab-starter scripts running. """ settings = prepare_system("*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings) self._settings = settings base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL]) creation_results = create_weblab_environment(base_url, settings) configure_web_server(creation_results) register_and_start_instance("*****@*****.**", self.wcloud_settings) start_port, end_port = creation_results[ "start_port"], creation_results["end_port"] finish_deployment("*****@*****.**", settings, start_port, end_port, self.wcloud_settings) pass
def test_finish_deployment_thorough(self): """ test_finish_deployment_thorough: Tests that every step can be done, and the deployment finished. Checks that after being configured, Apache is indeed serving the new instance correctly. PRERREQUISITES: apache-reloader and weblab-starter scripts running; apache2 configured correctly to load the instances. """ settings = prepare_system( "*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings ) self._settings = settings base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL]) creation_results = create_weblab_environment(base_url, settings) configure_web_server(creation_results) register_and_start_instance("*****@*****.**", self.wcloud_settings) start_port, end_port = creation_results["start_port"], creation_results["end_port"] finish_deployment("*****@*****.**", settings, start_port, end_port, self.wcloud_settings) # Check that the new instance is being served correctly. bot = requests.Session() r = bot.get("http://localhost/testentity/weblab/client/index.html") text = r.text print text assert "weblabclientlab" in text assert "input" in text assert "hiddenPassword" in text # Check that we can login with admin/password. r = bot.post( "http://localhost/testentity/weblab/login/json/", data="""{"params":{"username":"******", "password":"******"}, "method":"login"}""", ) str = r.text print "The request returned: " + str j = json.loads(str) assert not j["is_exception"] assert "id" in j["result"]