view src/ltpdarepo/tests/test_browser.py @ 0:c812c3020b63

Initial import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Thu, 09 Jun 2011 13:16:24 +0200
parents
children
line wrap: on
line source

import unittest

from ltpdarepo.tests import Browser
from ltpdarepo.tests import USERNAME, PASSWORD


class TestCase(unittest.TestCase):

    def setUp(self):
        self.browser = Browser('http://localhost/')

    def test_login(self):
        self.browser.open('/')
        self.assertEqual(self.browser.url, 'http://localhost/login')

        self.browser.getForm().getControl(name='username').value = USERNAME
        self.browser.getForm().getControl(name='password').value = PASSWORD
        self.browser.getForm().submit()

        self.assertEqual(self.browser.url, 'http://localhost/')

    def test_login_redirect(self):
        self.browser.open('/manage/databases/')
        print self.browser.url
        #self.assertEqual(self.browser.url, 'http://localhost/login')

        self.browser.getForm().getControl(name='username').value = USERNAME
        self.browser.getForm().getControl(name='password').value = PASSWORD
        self.browser.getForm().submit()

        self.assertEqual(self.browser.url, 'http://localhost/manage/databases/')

    def test_login_bad_redirect(self):
        self.browser.open('/login?next=http://google.com')
        print self.browser.url
        self.browser.getForm().getControl(name='username').value = USERNAME
        self.browser.getForm().getControl(name='password').value = PASSWORD
        self.browser.getForm().submit()
        print self.browser.url

    def test_foo(self):
        self.browser.open('/login?next=http%3A%2F%2Fgoogle.com')
        print self.browser.url
        self.browser.getForm().getControl(name='username').value = USERNAME
        self.browser.getForm().getControl(name='password').value = PASSWORD
        self.browser.getForm().submit()
        print self.browser.url


if __name__ == '__main__':
    unittest.main()