This test checks it makes sure the utility is enabled:

  >>> from zope.component import getUtility
  >>> from collective.regexredirector.interfaces import IRegexRedirectionStorage
  >>> from plone.app.redirector.interfaces import IRedirectionStorage
  >>> storage = getUtility(IRegexRedirectionStorage)
  >>> type(storage)
  <class 'collective.regexredirector.regexstorage.RegexRedirectionStorage'>

Let's create 1 folder then 2 documents on it and check:

  >>> self.setRoles(('Manager',))
  >>> browser = self.getBrowser()
  >>> browser.open('http://nohost/plone/')
  >>> browser.getLink(url='/createObject?type_name=Folder').click()
  >>> browser.getControl('Title').value = 'Foo'
  >>> browser.getControl('Save').click()
  >>> browser.contents
  '...Info...Changes saved...Foo...

  >>> browser.open('http://nohost/plone/foo/')
  >>> browser.getLink(url='/createObject?type_name=Document').click()
  >>> browser.getControl('Title').value = 'Bar'
  >>> browser.getControl('Save').click()
  >>> browser.contents
  '...Info...Changes saved...Bar...

  >>> browser.open('http://nohost/plone/foo/')
  >>> browser.getLink(url='/createObject?type_name=Document').click()
  >>> browser.getControl('Title').value = 'Test'
  >>> browser.getControl('Save').click()
  >>> browser.contents
  '...Info...Changes saved...Test...

We check that the folder is accessible:

  >>> browser.open('http://nohost/plone/foo')
  >>> browser.contents
  '...Foo...

We check that this url got a 404 response
  >>> browser.open('http://nohost/plone/toto')
  Traceback (most recent call last):
  ...
  HTTPError: HTTP Error 404: Not Found

We set in the control panel the different patterns:
  >>> browser.open('http://nohost/plone/@@regexredirector-settings')
  >>> browser.getControl(name='form.widgets.regex_values').value
  ''
  
  >>> browser.getControl(name='form.widgets.regex_values').value="'/toto'='/foo'\r\n'/tata/(?P<category_name>.+)'='/foo/\g<category_name>'"
  >>> browser.getControl(name='form.buttons.save').click()
  
We check that the differents patterns work:
  >>> browser.open('http://nohost/plone/toto')
  >>> browser.url
  'http://nohost/plone/foo'
  
  >>> browser.open('http://nohost/plone/tata/bar')
  >>> browser.url
  'http://nohost/plone/foo/bar'
  
  >>> browser.open('http://nohost/plone/tata/test')
  >>> browser.url
  'http://nohost/plone/foo/test'
  
  >>> browser.open('http://nohost/plone/tata/createObject?type_name=Document')
  >>> browser.getControl('Title').value = 'BaBa'
  >>> browser.getControl('Save').click()
  
  >>> browser.open('http://nohost/plone/tata/baba')
  >>> browser.url
  'http://nohost/plone/foo/baba'
