=========== Searching =========== It is possible to search for persons. There are some different search types. Set up ====== Visitors are allowed to search, so we log in as a visitor: >>> from icemac.addressbook.testing import Browser >>> browser = Browser() >>> browser.login('visitor') >>> browser.open('http://localhost/++skin++AddressBook/ab') There is a link in the global navigation which leads to the searches overview providing links to the offered search types: >>> browser.getLink('Search').click() >>> print browser.contents
- Keyword search
- Name search
      ...

    Keyword search
    ==============

    This search type allows to search for persons who have specified
    keywords assigned to:

    >>> browser.getLink('Keyword search').click()

    An explanation text is displayed:

    >>> [x.text for x in browser.etree.xpath("//div[@id='content']/div[2]")]
    ['The keywords you want to search for have to be in the right box. Use the arrow buttons to move them.']

    When no entry in the keywords field is selected no persons are found:

    >>> browser.getControl('Search').click()
    >>> print browser.contents
    <...No person found...

    When no person is found the same message is displayed:

    >>> browser.getControl('work').click()
    >>> browser.getControl('Search').click()
    >>> print browser.contents
    <...No person found...

    When selecting a keyword which leads to results they are displayed as
    a table with links to the edit forms of the found persons:

    >>> browser.getControl('work').click() # deselect keyword
    >>> browser.getControl('church').click()
    >>> browser.getControl('Search').click()
    >>> print browser.contents
last name first name
Koch
Liebig
Velleuer
      ...

    The form is displayed on the result page, too. The previously selected
    keyword is still selected:

    >>> browser.getControl('church').selected
    True

    The default serch term concatenator is `and`. When selecting multiple
    keywords only persons having all keywords are found:

    >>> browser.getControl('search term concatenation').displayValue
    ['and']
    >>> browser.getControl('family').click()
    >>> browser.getControl('Search').click()
    >>> print browser.contents
Koch
Velleuer
    ...

    By selecting `or` as search term concatenation all keyword having one
    of the selected keywords are found:

    >>> browser.getControl('or').click()
    >>> browser.getControl('keywords').displayValue = ['friends', 'family']
    >>> browser.getControl('Search').click()
    >>> print browser.contents
Hohmuth
Koch
Velleuer
... Name search =========== This search type allows to search for the name of a person (or parts of it using wildcards): >>> browser.getLink('Name search').click() When nothig is entered in the search field an error message is displayed: >>> browser.getControl('Search').click() >>> print browser.contents
There were some errors.

- Name of a person:
  Required input is missing.

     ...

    When no person is found the a message is displayed:

    >>> browser.getControl('Name').value = 'Unknown'
    >>> browser.getControl('Search').click()
    >>> print browser.contents
    <...No person found...

    When entering a search term which leads to results they are displayed as
    a table with links to the edit forms of the found persons:

    >>> browser.getControl('Name').value = 'Lie*'
    >>> browser.getControl('Search').click()
    >>> print browser.contents
Liebig
Tester Liese
...