def test_save_page_object_code(self, permanent_project_fixture): project = permanent_project_fixture['name'] testdir = permanent_project_fixture['testdir'] page_name = 'page_name_x1' parents = ['save', 'page', 'code'] page_object.new_page_object(testdir, project, parents, page_name, add_parents=True) page_code = ("elem1 = ('id', 'x')\n" "elem2 = ('id', 'y')\n" "def func1():\n" " pass") full_page_name = '{}.{}'.format('.'.join(parents), page_name) page_object.save_page_object_code(testdir, project, full_page_name, page_code) full_path = os.path.join(testdir, 'projects', project, 'pages', os.sep.join(parents), page_name + '.py') with open(full_path) as page_file: content = page_file.read() assert content == page_code
def save_page_object_code(): if request.method == 'POST': projectname = request.json['project'] page_object_name = request.json['pageObjectName'] content = request.json['content'] error = utils.code_syntax_is_valid(content) page_object.save_page_object_code(root_path, projectname, page_object_name, content) return json.dumps(error)
def save_page_object_code(): if request.method == 'POST': project = request.json['project'] page_object_name = request.json['pageObjectName'] content = request.json['content'] path = page_object.page_file_path(project, page_object_name) page_object.save_page_object_code(project, page_object_name, content) _, error = utils.import_module(path) return json.dumps({'error': error})
def save_page_object_code(): if request.method == 'POST': project = request.json['project'] page_object_name = request.json['pageObjectName'] content = request.json['content'] path = page_object.generate_page_path(root_path, project, page_object_name) page_object.save_page_object_code(root_path, project, page_object_name, content) error = utils.validate_python_file_syntax(path) return json.dumps({'error': error})
def save_page_object_code(): if request.method == 'POST': project = request.json['project'] page_object_name = request.json['pageObjectName'] content = request.json['content'] path = page_object.generate_page_path(root_path, project, page_object_name) page_object.save_page_object_code(root_path, project, page_object_name, content) error = utils.validate_python_file_syntax(path) return json.dumps({'error': error})
def test_save_page_object_code(self, project_session): _, project = project_session.activate() page_name = 'page_name_x1' parents = ['save', 'page', 'code'] page_object.new_page_object(project, parents, page_name) page_code = ("elem1 = ('id', 'x')\n" "elem2 = ('id', 'y')\n" "def func1():\n" " pass") full_page_name = '{}.{}'.format('.'.join(parents), page_name) page_object.save_page_object_code(project, full_page_name, page_code) full_path = os.path.join(project_session.path, 'pages', os.sep.join(parents), page_name + '.py') with open(full_path) as page_file: content = page_file.read() assert content == page_code