changeset 239:4d218e82d203 stable

Add doctest for Atom Feed
author Daniele Nicolodi <daniele@grinta.net>
date Tue, 13 Dec 2011 18:51:43 +0100
parents 3fee7db86a99
children 6b8153a4537e
files src/ltpdarepo/tests/browse-feed.txt src/ltpdarepo/tests/test_doctests.py
diffstat 2 files changed, 39 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ltpdarepo/tests/browse-feed.txt	Tue Dec 13 18:51:43 2011 +0100
@@ -0,0 +1,37 @@
+Test setup::
+
+    >>> from ltpdarepo.tests.utils import Browser
+    >>> USERNAME, PASSWORD = 'u1', 'u1'
+    >>> browser = Browser()
+    >>> browser.login(USERNAME, PASSWORD)
+    >>> browser.open('/')
+
+Obtain link to Atom Feed::
+
+    >>> browser.open('/browse/db1/')
+    >>> browser.getLink(url='atom.xml').url
+    'http://localhost/browse/db1/.../atom.xml'
+
+Check that Atom Feed renders correctly::
+
+    >>> browser.getLink(url='atom.xml').click()
+    
+Check Atom Feed properties::
+
+    >>> browser.contents # title is database name
+    '...<title type="text">db1</title>...'
+
+    >>> browser.contents # subtitle is database description
+    '...<subtitle type="text">Test database One</subtitle>...'
+    
+    >>> browser.contents # id should be an absolute url
+    '...<id>http://localhost/browse/db1/.../atom.xml</id>...'
+    
+    >>> browser.contents # as well as other links
+    '...<link href="http://localhost/browse/db1/" />...'
+
+Check that the authorization token is verified::
+
+    >>> browser.open('/browse/db1/xxx/atom.xml')
+    Traceback (most recent call last):
+    HTTPError: HTTP Error 403: FORBIDDEN
--- a/src/ltpdarepo/tests/test_doctests.py	Mon Dec 12 16:12:32 2011 +0100
+++ b/src/ltpdarepo/tests/test_doctests.py	Tue Dec 13 18:51:43 2011 +0100
@@ -7,7 +7,7 @@
     app = admin.Application()
     app.wipe()
     app.install()
-    app.createdb('db1')
+    app.createdb('db1', description='Test database One')
     app.populate('db1', 30)
     app.useradd('u1', admin=True)
     app.passwd('u1', 'u1')
@@ -26,6 +26,7 @@
         doctest.DocFileSuite(
             'browse-user.txt',
             'browse-database.txt',
+            'browse-feed.txt',
             'manage-users.txt',
             'manage-databases.txt',
             'manage-queries.txt',