changeset 75:f9d554de3793

Add doctest that execises the database browsing views.
author Daniele Nicolodi <daniele@grinta.net>
date Mon, 15 Aug 2011 20:06:30 +0200
parents b8c1ce741745
children 7811ee35b466
files src/ltpdarepo/tests/browse-database.txt src/ltpdarepo/tests/test_doctests.py
diffstat 2 files changed, 73 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ltpdarepo/tests/browse-database.txt	Mon Aug 15 20:06:30 2011 +0200
@@ -0,0 +1,68 @@
+Test setup::
+
+    >>> from ltpdarepo.tests.utils import Browser
+    >>> USERNAME, PASSWORD = 'u1', 'u1'
+    >>> browser = Browser()
+    >>> browser.login(USERNAME, PASSWORD)
+    >>> browser.open('/')
+
+Check that all the views render correctly. Obtain the database view::
+
+    >>> browser.getLink('db1').click()
+    >>> browser.url
+    'http://localhost/browse/db1/'
+
+Objects listing::
+
+    >>> browser.open('/browse/db1')
+    >>> browser.getLink('Browse').click()
+    >>> browser.url
+    'http://localhost/browse/db1/objs'
+
+Get first object::
+
+    >>> browser.open('/browse/db1/1')
+    >>> browser.url
+    'http://localhost/browse/db1/1'
+
+and its XML representations::
+
+    >>> browser.open('/browse/db1/1/xml')
+
+
+The test objects do not have a binary representation in the database::
+
+    >>> browser.open('/browse/db1/1/mat')
+    Traceback (most recent call last):
+    ...
+    HTTPError: HTTP Error 404: NOT FOUND
+
+Simple search::
+
+    >>> browser.open('/browse/db1')
+    >>> browser.getControl(name='q').value = ''
+    >>> browser.getForm().submit()
+    >>> browser.url
+    'http://localhost/browse/db1/search?q='
+
+Advabced search::
+
+    >>> browser.open('/browse/db1')
+    >>> browser.getLink('Advanced search').click()
+    >>> browser.url
+    'http://localhost/browse/db1/query'
+
+Timeseries search::
+
+    >>> browser.open('/browse/db1')
+    >>> browser.getLink('Timeseries search').click()
+    >>> browser.url
+    'http://localhost/browse/db1/timeseries'
+
+Activity view::
+
+    >>> browser.open('/browse/db1')
+    >>> browser.getLink('Show activity').click()
+    >>> browser.url
+    'http://localhost/browse/db1/activity'
+
--- a/src/ltpdarepo/tests/test_doctests.py	Mon Aug 15 20:06:27 2011 +0200
+++ b/src/ltpdarepo/tests/test_doctests.py	Mon Aug 15 20:06:30 2011 +0200
@@ -3,12 +3,14 @@
 
 
 def doctestSetUp(self):
-    from ltpdarepo.admin import wipe, install, useradd, grant, createdb
+    from ltpdarepo.admin import wipe, install, useradd, grant, createdb, populate
     wipe()
     install()
     useradd('u1', 'u1')
-    grant('u1', '%', ['admin', ])
+    grant('u1', '%', ('admin', ))
     createdb('db1')
+    grant('u1', 'db1', ('select', ))
+    populate('db1', 30)
 
 
 def doctestTearDown(self):
@@ -21,6 +23,7 @@
     suite.addTest(
         doctest.DocFileSuite(
             'browse-user.txt',
+            'browse-database.txt',
             'manage-users.txt',
             'manage-databases.txt',
             setUp=doctestSetUp, tearDown=doctestTearDown,