Commit 5a0b3763 authored by Roque's avatar Roque Committed by Sebastien Robin

testbrowser: refactor in browser due to new version of package zope.testbrowser.

An update in zope.testbrowser dropped the mechanize dependency used by the browser. Now it uses WebTest instead.

Details of the update:
parent 03a559c2
......@@ -9,7 +9,7 @@
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# consequences resulting from its eventual inadequacies and bugsc
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
......@@ -36,7 +36,7 @@ import urllib
from urlparse import urljoin
from z3c.etestbrowser.browser import ExtendedTestBrowser
from zope.testbrowser.browser import onlyOne, fix_exception_name
from zope.testbrowser.browser import onlyOne
def measurementMetaClass(prefix):
......@@ -234,7 +234,6 @@ class Browser(ExtendedTestBrowser):
response = self.mech_browser.open_novisit(url_or_path, data)
except Exception, e:
except mechanize.HTTPError, e:
if e.code >= 200 and e.code <= 299:
......@@ -317,17 +316,10 @@ class Browser(ExtendedTestBrowser):
# just return the main_form instance
if self._main_form and self._counter == self._main_form._browser_counter:
return self._main_form
main_form = None
for form in self.mech_browser.forms():
if form.attrs.get('id') == 'main_form':
main_form = form
main_form = self.getForm(id='main_form')._form
if not main_form:
raise LookupError("Could not get 'main_form'")
self.mech_browser.form = form
self._main_form = ContextMainForm(self, form)
self._main_form = ContextMainForm(self, main_form)
return self._main_form
def getLink(self, text=None, url=None, id=None, index=0,
......@@ -704,9 +696,9 @@ class MainForm(Form):
if index is None:
index = 0
super(MainForm, self).submit(label=label, name=name, index=index,
*args, **kwargs)
def submitSelect(self, select_name, submit_name, label=None, value=None,
select_index=None, control_index=None):
......@@ -747,8 +739,8 @@ class MainForm(Form):
@raise LookupError: The select, option or submit control could not
be found
select_control = self.getControl(name=select_name, index=select_index)
# zope.testbrowser checks for a whole word but it is also useful
# to match the end of the option control value string because in
# ERP5, the value could be URL (such as 'http://foo:81/erp5/logout')
......@@ -760,13 +752,10 @@ class MainForm(Form):
if item.endswith(value):
value = item
self._logger.debug("select_id='%s', label='%s', value='%s'" % \
(select_name, label, value))
select_control.getControl(label=label, value=value,
index=control_index).selected = True
def submitLogin(self):
......@@ -809,6 +798,12 @@ class MainForm(Form):
import Cookie
cookie = Cookie.SimpleCookie()
ac_value = cookie['__ac'].value
self.browser.cookies["__ac"] = ac_value
def submitSelectFavourite(self, label=None, value=None, **kw):
......@@ -1187,7 +1182,6 @@ class ContextMainForm(MainForm):
# control), then get the item from its value
if isinstance(control, ListControl):
control = control.getControl(value=input_element.get('value'))
return control
from zope.testbrowser.browser import SubmitControl
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment