16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 |
18 |
19 from cubicweb.devtools.testlib import CubicWebTC |
19 from cubicweb.devtools.testlib import CubicWebTC |
20 from cubicweb.devtools.htmlparser import XMLValidator |
20 from cubicweb.devtools.htmlparser import XMLValidator |
|
21 from cubicweb.dbapi import DBAPISession |
21 |
22 |
22 |
23 |
23 class LogFormTemplateTC(CubicWebTC): |
24 class LogFormTemplateTC(CubicWebTC): |
24 |
25 |
25 def _login_labels(self): |
26 def _login_labels(self): |
26 valid = self.content_type_validators.get('text/html', XMLValidator)() |
27 valid = self.content_type_validators.get('text/html', XMLValidator)() |
27 req = self.request() |
28 req = self.requestcls(self.vreg, url='login') |
28 req.cnx.anonymous_connection = True |
29 page = valid.parse_string(self.vreg['views'].main_template(req, 'login')) |
29 page = valid.parse_string(self.vreg['views'].main_template(self.request(), 'login')) |
|
30 req.cnx.anonymous_connection = False |
|
31 return page.find_tag('label') |
30 return page.find_tag('label') |
32 |
31 |
33 def test_label(self): |
32 def test_label(self): |
34 self.set_option('allow-email-login', 'yes') |
33 self.set_option('allow-email-login', 'yes') |
35 self.assertEqual(self._login_labels(), ['login or email', 'password']) |
34 self.assertEqual(self._login_labels(), ['login or email', 'password']) |