<s> from django . template import Template , Context <EOL> from django . conf import settings <EOL> from django . test import TestCase <EOL> from shorturls . tests . models import Animal , Vegetable , Mineral <EOL> class TemplateTagTestCase ( TestCase ) : <EOL> urls = '<STR_LIT>' <EOL> fixtures = [ '<STR_LIT>' ] <EOL> def setUp ( self ) : <EOL> self . old_shorten = getattr ( settings , '<STR_LIT>' , None ) <EOL> self . old_base = getattr ( settings , '<STR_LIT>' , None ) <EOL> settings . SHORT_BASE_URL = None <EOL> settings . SHORTEN_MODELS = { <EOL> '<STR_LIT:A>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> def tearDown ( self ) : <EOL> if self . old_shorten is not None : <EOL> settings . SHORTEN_MODELS = self . old_shorten <EOL> if self . old_base is not None : <EOL> settings . SHORT_BASE_URL = self . old_base <EOL> def render ( self , t , ** c ) : <EOL> return Template ( '<STR_LIT>' + t ) . render ( Context ( c ) ) <EOL> def test_shorturl ( self ) : <EOL> r = self . render ( '<STR_LIT>' , a = Animal . objects . get ( id = <NUM_LIT> ) ) <EOL> self . assertEqual ( r , '<STR_LIT>' ) <EOL> def test_bad_context ( self ) : <EOL> r = self . render ( '<STR_LIT>' ) <EOL> self . assertEqual ( r , '<STR_LIT>' ) <EOL> def test_no_prefix ( self ) : <EOL> r = self . render ( '<STR_LIT>' , m = Mineral . objects . all ( ) [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( r , '<STR_LIT>' ) <EOL> def test_short_base_url ( self ) : <EOL> settings . SHORT_BASE_URL = '<STR_LIT>' <EOL> r = self . render ( '<STR_LIT>' , a = Animal . objects . get ( id = <NUM_LIT> ) ) <EOL> self . assertEqual ( r , '<STR_LIT>' ) <EOL> def test_revcanonical ( self ) : <EOL> r = self . render ( '<STR_LIT>' , a = Animal . objects . get ( id = <NUM_LIT> ) ) <EOL> self . assertEqual ( r , '<STR_LIT>' ) </s>
