From e7b76e3eff53b66302589b5e9c7a0ac55137d547 Mon Sep 17 00:00:00 2001 From: Richard Hitier Date: Mon, 17 May 2021 11:48:42 +0200 Subject: [PATCH] Fix edit project name was inoperant --- app/models.py | 1 + tests/frontend_tests.py | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index bd97cab..3f21244 100644 --- a/app/models.py +++ b/app/models.py @@ -67,6 +67,7 @@ class Project(db.Model, Formable): :param form_request: :return: """ + struct = super(Project, self).from_request(form_request) self.labels.clear() form_labels = [] for _c in Category.query.all(): diff --git a/tests/frontend_tests.py b/tests/frontend_tests.py index b8093b9..4c3d08c 100644 --- a/tests/frontend_tests.py +++ b/tests/frontend_tests.py @@ -9,7 +9,7 @@ from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.select import Select from app import create_app -from app.models import Agent, Charge +from app.models import Agent, Charge, Project from pdc_config import TestConfig from tests.common_db_feed import resources_to_instancedb @@ -181,6 +181,24 @@ class FormsTestCase(BaseFrontTestCase): latest_agent = Agent.query.filter(Agent.id == 1).one() self.assertEqual('Hitier', latest_agent.firstname) + # Test project form + def test_project_edit(self): + project_name = "My Project Name" + # load the form + target_url = self.get_server_url() + url_for('main.project_edit', project_id=1) + self.driver.get(target_url) + # fill it in + name_input = self.driver.find_elements_by_xpath("//input[@id='name']")[0] + self.assertTrue("GRAIN" in name_input.get_attribute('value')) + name_input.clear() + name_input.send_keys(project_name) + # submit + submit_button = self.driver.find_elements_by_xpath("//input[@type='submit']")[0] + submit_button.send_keys(Keys.ENTER) + # check on database + latest_agent = Project.query.filter(Project.id == 1).one() + self.assertEqual(project_name, latest_agent.name) + # Test charge form add new def test_charge_add(self): # load the form -- libgit2 0.21.2