<s> import re <EOL> from django . conf import settings <EOL> from django . template import Context <EOL> from django . template import Template <EOL> from django . utils . text import normalize_newlines <EOL> from horizon . test import helpers as test <EOL> from horizon . test . test_dashboards . cats . dashboard import Cats <EOL> from horizon . test . test_dashboards . cats . kittens . panel import Kittens <EOL> from horizon . test . test_dashboards . dogs . dashboard import Dogs <EOL> from horizon . test . test_dashboards . dogs . puppies . panel import Puppies <EOL> def single_line ( text ) : <EOL> """<STR_LIT>""" <EOL> return re . sub ( '<STR_LIT>' , <EOL> '<STR_LIT:U+0020>' , <EOL> normalize_newlines ( text ) . replace ( '<STR_LIT:\n>' , '<STR_LIT>' ) ) . strip ( ) <EOL> class TemplateTagTests ( test . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def render_template_tag ( self , tag_name , tag_require = '<STR_LIT>' ) : <EOL> tag_call = "<STR_LIT>" % tag_name <EOL> return self . render_template ( tag_call , tag_require ) <EOL> def render_template ( self , template_text , tag_require = '<STR_LIT>' , context = None ) : <EOL> """<STR_LIT>""" <EOL> context = context or { } <EOL> template = Template ( "<STR_LIT>" <EOL> % ( tag_require , template_text ) ) <EOL> return template . render ( Context ( context ) ) <EOL> def test_site_branding_tag ( self ) : <EOL> """<STR_LIT>""" <EOL> rendered_str = self . render_template_tag ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( settings . SITE_BRANDING , rendered_str . strip ( ) , <EOL> "<STR_LIT>" % rendered_str . strip ( ) ) <EOL> def test_size_format_filters ( self ) : <EOL> size_str = ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> expected = u'<STR_LIT>' <EOL> text = '<STR_LIT>' <EOL> for size_filter in size_str : <EOL> text += '<STR_LIT>' + size_filter + '<STR_LIT>' <EOL> rendered_str = self . render_template ( tag_require = '<STR_LIT>' , <EOL> template_text = text ) <EOL> self . assertEqual ( expected , rendered_str ) <EOL> def test_size_format_filters_with_string ( self ) : <EOL> size_str = ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> expected = u'<STR_LIT>' <EOL> text = '<STR_LIT>' <EOL> for size_filter in size_str : <EOL> text += '<STR_LIT>' + size_filter + '<STR_LIT>' <EOL> rendered_str = self . render_template ( tag_require = '<STR_LIT>' , <EOL> template_text = text ) <EOL> self . assertEqual ( expected , rendered_str ) <EOL> def test_truncate_filter ( self ) : <EOL> ctx_string = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> text = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> expected = u'<STR_LIT>' <EOL> rendered_str = self . render_template ( tag_require = '<STR_LIT>' , <EOL> template_text = text , <EOL> context = { '<STR_LIT:test>' : ctx_string } ) <EOL> self . assertEqual ( expected , rendered_str ) <EOL> def test_quota_filter ( self ) : <EOL> ctx_string = { '<STR_LIT>' : <NUM_LIT:100> , <EOL> '<STR_LIT>' : <NUM_LIT:1000> , <EOL> '<STR_LIT>' : float ( '<STR_LIT>' ) } <EOL> text = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> expected = u'<STR_LIT>' <EOL> rendered_str = self . render_template ( tag_require = '<STR_LIT>' , <EOL> template_text = text , <EOL> context = { '<STR_LIT:test>' : ctx_string } ) <EOL> self . assertEqual ( expected , rendered_str ) <EOL> def test_horizon_main_nav ( self ) : <EOL> text = "<STR_LIT>" <EOL> expected = """<STR_LIT>""" <EOL> rendered_str = self . render_template ( tag_require = '<STR_LIT>' , <EOL> template_text = text , <EOL> context = { '<STR_LIT>' : self . request } ) <EOL> self . assertEqual ( single_line ( rendered_str ) , single_line ( expected ) ) </s>
