Commit e7b76e3eff53b66302589b5e9c7a0ac55137d547

Authored by hitier
1 parent bf0e0b24

Fix edit project name was inoperant

Showing 2 changed files with 20 additions and 1 deletions   Show diff stats
app/models.py
... ... @@ -67,6 +67,7 @@ class Project(db.Model, Formable):
67 67 :param form_request:
68 68 :return:
69 69 """
  70 + struct = super(Project, self).from_request(form_request)
70 71 self.labels.clear()
71 72 form_labels = []
72 73 for _c in Category.query.all():
... ...
tests/frontend_tests.py
... ... @@ -9,7 +9,7 @@ from selenium.webdriver.common.keys import Keys
9 9 from selenium.webdriver.support.select import Select
10 10  
11 11 from app import create_app
12   -from app.models import Agent, Charge
  12 +from app.models import Agent, Charge, Project
13 13 from pdc_config import TestConfig
14 14 from tests.common_db_feed import resources_to_instancedb
15 15  
... ... @@ -181,6 +181,24 @@ class FormsTestCase(BaseFrontTestCase):
181 181 latest_agent = Agent.query.filter(Agent.id == 1).one()
182 182 self.assertEqual('Hitier', latest_agent.firstname)
183 183  
  184 + # Test project form
  185 + def test_project_edit(self):
  186 + project_name = "My Project Name"
  187 + # load the form
  188 + target_url = self.get_server_url() + url_for('main.project_edit', project_id=1)
  189 + self.driver.get(target_url)
  190 + # fill it in
  191 + name_input = self.driver.find_elements_by_xpath("//input[@id='name']")[0]
  192 + self.assertTrue("GRAIN" in name_input.get_attribute('value'))
  193 + name_input.clear()
  194 + name_input.send_keys(project_name)
  195 + # submit
  196 + submit_button = self.driver.find_elements_by_xpath("//input[@type='submit']")[0]
  197 + submit_button.send_keys(Keys.ENTER)
  198 + # check on database
  199 + latest_agent = Project.query.filter(Project.id == 1).one()
  200 + self.assertEqual(project_name, latest_agent.name)
  201 +
184 202 # Test charge form add new
185 203 def test_charge_add(self):
186 204 # load the form
... ...