Commit c151302b2ba6a526d0f54a2b06b47c8e90923b9d

Authored by hitier
1 parent 12b45266

New selenium tests form edit

Showing 1 changed file with 25 additions and 3 deletions   Show diff stats
tests/frontend_tests.py
1 1 import os
  2 +import unittest
2 3 import urllib.request
3 4  
4 5 from flask import url_for
... ... @@ -122,8 +123,7 @@ class AccessTestCase(BaseFrontTestCase):
122 123  
123 124 class FormsTestCase(BaseFrontTestCase):
124 125  
125   - # Test agemt form
126   - def test_agent_edit(self):
  126 + def test_agent_add(self):
127 127 # load the form
128 128 target_url = self.get_server_url() + url_for('main.agent_edit')
129 129 self.driver.get(target_url)
... ... @@ -139,7 +139,24 @@ class FormsTestCase(BaseFrontTestCase):
139 139 latest_agent = Agent.query.order_by(Agent.id.desc()).all()[0]
140 140 self.assertEqual('Hitier', latest_agent.firstname)
141 141  
142   - # Test agemt form
  142 + # Test agent form
  143 + def test_agent_edit(self):
  144 + # load the form
  145 + target_url = self.get_server_url() + url_for('main.agent_edit', agent_id=1)
  146 + self.driver.get(target_url)
  147 + # fill it in
  148 + firstname_input = self.driver.find_elements_by_xpath("//input[@id='firstname']")[0]
  149 + self.assertEqual("Dubois", firstname_input.get_attribute('value'))
  150 + firstname_input.clear()
  151 + firstname_input.send_keys("Hitier")
  152 + # # submit
  153 + submit_button = self.driver.find_elements_by_xpath("//input[@type='submit']")[0]
  154 + submit_button.send_keys(Keys.ENTER)
  155 + # # check on database
  156 + latest_agent = Agent.query.filter(Agent.id == 1).one()
  157 + self.assertEqual('Hitier', latest_agent.firstname)
  158 +
  159 + # Test charge form add new
143 160 def test_charge_add(self):
144 161 # load the form
145 162 target_url = self.get_server_url() + url_for('main.charge_add')
... ... @@ -171,3 +188,8 @@ class FormsTestCase(BaseFrontTestCase):
171 188 latest_charge.period_id,
172 189 latest_charge.charge_rate]
173 190 )
  191 +
  192 + # Test charge form edit existing
  193 + @unittest.skip("charge edit to be implemented")
  194 + def test_charge_edit(self):
  195 + pass
... ...