<s> import unittest <EOL> from flask import Flask , render_template_string <EOL> from flask . ext . mobility import Mobility <EOL> from flask . ext . mobility . decorators import mobile_template , mobilized <EOL> class DecoratorsTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> app = Flask ( __name__ ) <EOL> Mobility ( app ) <EOL> @ app . route ( '<STR_LIT:/>' ) <EOL> @ mobile_template ( '<STR_LIT>' ) <EOL> def index ( template ) : <EOL> return render_template_string ( template ) <EOL> def mobilize ( ) : <EOL> return render_template_string ( '<STR_LIT:False>' ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> @ mobilized ( mobilize ) <EOL> def mobilize ( ) : <EOL> return render_template_string ( '<STR_LIT:True>' ) <EOL> self . app = app <EOL> self . client = app . test_client ( ) <EOL> def test_mobile_template_user_agent ( self ) : <EOL> """<STR_LIT>""" <EOL> assert b'<STR_LIT>' == self . client . get ( '<STR_LIT:/>' ) . data <EOL> headers = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> response = self . client . get ( '<STR_LIT:/>' , headers = headers ) <EOL> assert b'<STR_LIT>' == response . data <EOL> def test_mobile_template_cookie ( self ) : <EOL> assert b'<STR_LIT>' == self . client . get ( '<STR_LIT:/>' ) . data <EOL> MOBILE_COOKIE = self . app . config . get ( '<STR_LIT>' ) <EOL> self . client . set_cookie ( '<STR_LIT:localhost>' , MOBILE_COOKIE , '<STR_LIT>' ) <EOL> assert b'<STR_LIT>' == self . client . get ( '<STR_LIT:/>' ) . data <EOL> self . client . set_cookie ( '<STR_LIT:localhost>' , MOBILE_COOKIE , '<STR_LIT>' ) <EOL> assert b'<STR_LIT>' == self . client . get ( '<STR_LIT:/>' ) . data <EOL> def test_mobilized_user_agent ( self ) : <EOL> """<STR_LIT>""" <EOL> assert b'<STR_LIT:False>' == self . client . get ( '<STR_LIT>' ) . data <EOL> headers = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> assert b'<STR_LIT:True>' == self . client . get ( '<STR_LIT>' , headers = headers ) . data <EOL> def test_mobilized_cookie ( self ) : <EOL> assert b'<STR_LIT:False>' == self . client . get ( '<STR_LIT>' ) . data <EOL> MOBILE_COOKIE = self . app . config . get ( '<STR_LIT>' ) <EOL> self . client . set_cookie ( '<STR_LIT:localhost>' , MOBILE_COOKIE , '<STR_LIT>' ) <EOL> assert b'<STR_LIT:True>' == self . client . get ( '<STR_LIT>' ) . data <EOL> self . client . set_cookie ( '<STR_LIT:localhost>' , MOBILE_COOKIE , '<STR_LIT>' ) <EOL> assert b'<STR_LIT:False>' == self . client . get ( '<STR_LIT>' ) . data </s>
