<s> """<STR_LIT>""" <EOL> import re <EOL> from django . contrib . auth . models import User , AnonymousUser <EOL> from django . http import HttpRequest <EOL> from django . template import Context <EOL> from django . test . utils import override_settings <EOL> from analytical . templatetags . spring_metrics import SpringMetricsNode <EOL> from analytical . tests . utils import TagTestCase <EOL> from analytical . utils import AnalyticalException <EOL> @ override_settings ( SPRING_METRICS_TRACKING_ID = '<STR_LIT>' ) <EOL> class SpringMetricsTagTestCase ( TagTestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_tag ( self ) : <EOL> r = self . render_tag ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertTrue ( "<STR_LIT>" in r , r ) <EOL> def test_node ( self ) : <EOL> r = SpringMetricsNode ( ) . render ( Context ( { } ) ) <EOL> self . assertTrue ( "<STR_LIT>" in r , r ) <EOL> @ override_settings ( SPRING_METRICS_TRACKING_ID = None ) <EOL> def test_no_site_id ( self ) : <EOL> self . assertRaises ( AnalyticalException , SpringMetricsNode ) <EOL> @ override_settings ( SPRING_METRICS_TRACKING_ID = '<STR_LIT>' ) <EOL> def test_wrong_site_id ( self ) : <EOL> self . assertRaises ( AnalyticalException , SpringMetricsNode ) <EOL> @ override_settings ( ANALYTICAL_AUTO_IDENTIFY = True ) <EOL> def test_identify ( self ) : <EOL> r = SpringMetricsNode ( ) . render ( Context ( { '<STR_LIT:user>' : <EOL> User ( email = '<STR_LIT>' ) } ) ) <EOL> self . assertTrue ( "<STR_LIT>" <EOL> "<STR_LIT>" in r , r ) <EOL> @ override_settings ( ANALYTICAL_AUTO_IDENTIFY = True ) <EOL> def test_identify_anonymous_user ( self ) : <EOL> r = SpringMetricsNode ( ) . render ( Context ( { '<STR_LIT:user>' : AnonymousUser ( ) } ) ) <EOL> self . assertFalse ( "<STR_LIT>" in r , r ) <EOL> def test_custom ( self ) : <EOL> r = SpringMetricsNode ( ) . render ( Context ( { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } ) ) <EOL> self . assertTrue ( "<STR_LIT>" in r , <EOL> r ) <EOL> self . assertTrue ( "<STR_LIT>" in r , <EOL> r ) <EOL> @ override_settings ( ANALYTICAL_INTERNAL_IPS = [ '<STR_LIT>' ] ) <EOL> def test_render_internal_ip ( self ) : <EOL> req = HttpRequest ( ) <EOL> req . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> context = Context ( { '<STR_LIT>' : req } ) <EOL> r = SpringMetricsNode ( ) . render ( context ) <EOL> self . assertTrue ( r . startswith ( <EOL> '<STR_LIT>' ) , r ) <EOL> self . assertTrue ( r . endswith ( '<STR_LIT>' ) , r ) </s>
