web/test/unittest_views_basetemplates.py
author Katia Saurfelt <katia.saurfelt@logilab.fr>
Tue, 19 May 2009 11:44:06 +0200
branchstable
changeset 1863 9a02979a2c00
parent 1776 4be367276874
child 1977 606923dff11b
permissions -rw-r--r--
do not use <br> in widgets
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1776
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
     1
from cubicweb.devtools.testlib import WebTest
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
     2
from cubicweb.devtools.htmlparser import DTDValidator
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
     3
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
     4
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
     5
class LogFormTemplateTC(WebTest):
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
     6
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
     7
    def _login_labels(self):
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
     8
        valid = self.content_type_validators.get('text/html', DTDValidator)()
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
     9
        page = valid.parse_string(self.vreg.main_template(self.request(), 'login'))
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
    10
        return page.find_tag('label')
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
    11
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
    12
    def test_label(self):
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
    13
        self.set_option('allow-email-login', 'yes')
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
    14
        self.assertEquals(self._login_labels(), ['login or email', 'password'])
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
    15
        self.set_option('allow-email-login', 'no')
4be367276874 adapt login box message to allow-email-login configuration
Florent <florent@secondweb.fr>
parents:
diff changeset
    16
        self.assertEquals(self._login_labels(), ['login', 'password'])