<s> from django . conf import settings <EOL> from django . template import engines as template_engines <EOL> from django . template . loader import render_to_string <EOL> from django . test . client import RequestFactory <EOL> from django . utils import translation <EOL> import mock <EOL> from nose . tools import eq_ <EOL> from pyquery import PyQuery as pq <EOL> from kitsune . sumo . tests import LocalizingClient , TestCase <EOL> from kitsune . sumo . urlresolvers import reverse <EOL> def test_breadcrumb ( ) : <EOL> """<STR_LIT>""" <EOL> c = LocalizingClient ( ) <EOL> response = c . get ( reverse ( '<STR_LIT>' ) ) <EOL> doc = pq ( response . content ) <EOL> href = doc ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> eq_ ( '<STR_LIT:/>' , href . attrib [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> class MockRequestTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> super ( MockRequestTests , self ) . setUp ( ) <EOL> request = RequestFactory ( ) <EOL> request . GET = { } <EOL> request . LANGUAGE_CODE = '<STR_LIT>' <EOL> self . request = request <EOL> class BaseTemplateTests ( MockRequestTests ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> super ( BaseTemplateTests , self ) . setUp ( ) <EOL> self . template = '<STR_LIT>' <EOL> def test_dir_ltr ( self ) : <EOL> """<STR_LIT>""" <EOL> html = render_to_string ( self . template , request = self . request ) <EOL> eq_ ( '<STR_LIT>' , pq ( html ) ( '<STR_LIT:html>' ) . attr [ '<STR_LIT>' ] ) <EOL> def test_dir_rtl ( self ) : <EOL> """<STR_LIT>""" <EOL> translation . activate ( '<STR_LIT>' ) <EOL> self . request . LANGUAGE_CODE = '<STR_LIT>' <EOL> html = render_to_string ( self . template , request = self . request ) <EOL> eq_ ( '<STR_LIT>' , pq ( html ) ( '<STR_LIT:html>' ) . attr [ '<STR_LIT>' ] ) <EOL> translation . deactivate ( ) <EOL> def test_multi_feeds ( self ) : <EOL> """<STR_LIT>""" <EOL> feed_urls = ( ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , ) <EOL> doc = pq ( render_to_string ( self . template , { '<STR_LIT>' : feed_urls } , request = self . request ) ) <EOL> feeds = doc ( '<STR_LIT>' ) <EOL> eq_ ( <NUM_LIT:2> , len ( feeds ) ) <EOL> eq_ ( '<STR_LIT>' , feeds [ <NUM_LIT:0> ] . attrib [ '<STR_LIT:title>' ] ) <EOL> eq_ ( '<STR_LIT>' , feeds [ <NUM_LIT:1> ] . attrib [ '<STR_LIT:title>' ] ) <EOL> def test_readonly_attr ( self ) : <EOL> html = render_to_string ( self . template , request = self . request ) <EOL> doc = pq ( html ) <EOL> eq_ ( '<STR_LIT:false>' , doc ( '<STR_LIT:body>' ) [ <NUM_LIT:0> ] . attrib [ '<STR_LIT>' ] ) <EOL> @ mock . patch . object ( settings . _wrapped , '<STR_LIT>' , True ) <EOL> def test_readonly_login_link_disabled ( self ) : <EOL> """<STR_LIT>""" <EOL> html = render_to_string ( self . template , request = self . request ) <EOL> doc = pq ( html ) <EOL> eq_ ( <NUM_LIT:0> , len ( doc ( '<STR_LIT>' ) ) ) <EOL> @ mock . patch . object ( settings . _wrapped , '<STR_LIT>' , False ) <EOL> def test_not_readonly_login_link_enabled ( self ) : <EOL> """<STR_LIT>""" <EOL> html = render_to_string ( self . template , request = self . request ) <EOL> doc = pq ( html ) <EOL> assert len ( doc ( '<STR_LIT>' ) ) > <NUM_LIT:0> <EOL> class ErrorListTests ( MockRequestTests ) : <EOL> """<STR_LIT>""" <EOL> def test_escaping ( self ) : <EOL> """<STR_LIT>""" <EOL> class MockForm ( object ) : <EOL> errors = True <EOL> auto_id = '<STR_LIT>' <EOL> def visible_fields ( self ) : <EOL> return [ { '<STR_LIT>' : [ '<STR_LIT>' ] } ] <EOL> def non_field_errors ( self ) : <EOL> return [ '<STR_LIT>' ] <EOL> source = ( """<STR_LIT>""" <EOL> """<STR_LIT>""" ) <EOL> template = template_engines [ '<STR_LIT>' ] . from_string ( source ) <EOL> html = template . render ( { '<STR_LIT>' : MockForm ( ) } ) <EOL> assert '<STR_LIT>' not in html <EOL> assert '<STR_LIT>' in html <EOL> assert '<STR_LIT>' in html </s>
