def test_edit_page(self, project_session, test_utils): _, project = project_session.activate() page_name = test_utils.create_random_page(project) elements = [ {'name': 'a', 'selector': 'id', 'value': 'b', 'display_name': 'a'}, {'name': 'c', 'selector': 'id', 'value': 'd', 'display_name': ''} ] functions = ["def func1(a, b):\n print(a, b)\n"] import_lines = [ 'import time', 'from golem import browser' ] page.edit_page(project, page_name, elements, functions, import_lines) expected_contents = ('import time\n' 'from golem import browser\n' '\n' '\n' 'a = (\'id\', \'b\', \'a\')\n' '\n' 'c = (\'id\', \'d\', \'c\')\n' '\n' 'def func1(a, b):\n' ' print(a, b)\n') with open(Page(project, page_name).path) as f: assert f.read() == expected_contents
def page_save(): project = request.json['project'] page_name = request.json['pageName'] elements = request.json['elements'] functions = request.json['functions'] import_lines = request.json['importLines'] _verify_permissions(Permissions.STANDARD, project) page_module.edit_page(project, page_name, elements, functions, import_lines) return jsonify('page-saved')
def test_edit_page_selector_value_format(self, value, expected_value, project_session, test_utils): _, project = project_session.activate() page_name = test_utils.create_random_page(project) elements = [ {'name': 'foo', 'selector': 'id', 'value': value, 'display_name': 'foo'}, ] page.edit_page(project, page_name, elements, [], []) elements = Page(project, page_name).components['elements'] assert elements[0]['value'] == expected_value