Browse files

Pages: add concat_portal_url helper method.

  • Loading branch information...
1 parent c5055ff commit c1a6ee75fe3a60beab4ed7843cb8c97e7caf107a @jone jone committed Mar 24, 2013
Showing with 20 additions and 10 deletions.
  1. +10 −10 ftw/testing/pages.py
  2. +10 −0 ftw/testing/tests/test_pages_pageobject.py
View
20 ftw/testing/pages.py
@@ -30,6 +30,11 @@ def portal_url(self):
return 'http://%s:%s/%s' % (host, port, PLONE_SITE_ID)
+ def concat_portal_url(self, *path):
+ """Concats the portal url with one or more bits of path.
+ """
+ return '/'.join((self.portal_url,) + path)
+
@property
def browser_driver(self):
"""Returns the name (string) of the browser driver currently in use.
@@ -80,19 +85,15 @@ def normalize_whitespace(self, text):
class Plone(PageObject):
- def visit_portal(self, path=None):
- if path:
- url = '/'.join((self.portal_url, path))
- else:
- url = self.portal_url
-
- locals()['__traceback_info__'] = path
+ def visit_portal(self, *paths):
+ url = self.concat_portal_url(*paths)
+ locals()['__traceback_info__'] = (paths, ':', url)
browser().visit(url)
return self
def login(self, user=TEST_USER_NAME, password=TEST_USER_PASSWORD):
# This should be implemented by setting request headers.
- browser().visit(self.portal_url + '/login')
+ browser().visit(self.concat_portal_url('login'))
browser().fill('__ac_name', user)
browser().fill('__ac_password', password)
browser().find_by_xpath(
@@ -252,8 +253,7 @@ def save(self):
class PloneControlPanel(Plone):
def open(self):
- browser().visit('/'.join((
- self.portal_url, '@@overview-controlpanel')))
+ browser().visit(self.concat_portal_url('@@overview-controlpanel'))
return self
def assert_on_control_panel(self):
View
10 ftw/testing/tests/test_pages_pageobject.py
@@ -31,6 +31,16 @@ def test_browser_driver__ZOPE_TESTBROWSER(self):
PageObject().browser_driver,
'Expected browser driver to be "zope.testbrowser"')
+ def test_concat_portal_url(self):
+ self.assertEquals('http://nohost/plone',
+ PageObject().concat_portal_url())
+
+ self.assertEquals('http://nohost/plone/foo',
+ PageObject().concat_portal_url('foo'))
+
+ self.assertEquals('http://nohost/plone/foo/bar',
+ PageObject().concat_portal_url('foo', 'bar'))
+
@javascript
def test_browser_driver__PHANTOMS(self):
self.assertEquals(

0 comments on commit c1a6ee7

Please sign in to comment.