view src/ltpdarepo/tests/browse-search.txt @ 241:32c4e938787e stable

Extend tests.
author Daniele Nicolodi <daniele@grinta.net>
date Fri, 16 Dec 2011 19:09:12 +0100
parents
children
line wrap: on
line source

Test setup::

    >>> from urllib import urlencode
    >>> from ltpdarepo.tests.utils import Browser
    >>> USERNAME, PASSWORD = 'u1', 'u1'
    >>> browser = Browser()
    >>> browser.login(USERNAME, PASSWORD)

Build a simple query without using the web interface::

    >>> params = urlencode((('field', 'id'),('operator', '<'),('value', '11'),
    ...                     ('field', 'name'),('operator', 'LIKE'),('value', '%')))
    >>> browser.open('/browse/db1/query?' + params)

We should obtain 10 objects::

    >>> browser.contents.count('<td class="id">')
    10

Try different query builder interface field type parsers::

    >>> params = urlencode((('field', 'submitted'),('operator', '>'),('value', '1970-01-01 00:00:00 UTC'), # datetime
    ...                     ('field', 'type'),('operator', '='),('value', 'ao'))) # enum
    >>> browser.open('/browse/db1/query?' + params)

We should obtain all 30 objects::

    >>> browser.contents.count('<td class="id">')
    30

Same query through the timespan search interface::

    >>> params = urlencode((('field', 'id'),('operator', '<'),('value', '11'),
    ...                     ('field', 'name'),('operator', 'LIKE'),('value', '%')))
    >>> browser.open('/browse/db1/timeseries?' + params)

We should still obtain 10 objects::

    >>> browser.contents.count('<td class="id">')
    10

Add timespan constraints::

    >>> params = urlencode((('field', 'id'),('operator', '<'),('value', '11'),
    ...                     ('field', 'name'),('operator', 'LIKE'),('value', '%'),
    ...                     ('t1', '1970-01-01 00:00:00 UTC'),
    ...                     ('t2', '1970-01-01 00:10:00 UTC')))
    >>> browser.open('/browse/db1/timeseries?' + params)

This time we should obtain just 7 objects::

    >>> browser.contents.count('<td class="id">')
    7

Timespan constraints in CET timezone::

    >>> params = urlencode((('field', 'id'),('operator', '<'),('value', '11'),
    ...                     ('field', 'name'),('operator', 'LIKE'),('value', '%'),
    ...                     ('t1', '1970-01-01 01:00:00 CET'),
    ...                     ('t2', '1970-01-01 01:10:00 CET')))
    >>> browser.open('/browse/db1/timeseries?' + params)

We should obtain the same 7 objects::

    >>> browser.contents.count('<td class="id">')
    7


# Local Variables:
# mode: doctest
# End: