<s> """<STR_LIT>""" <EOL> from django . http import HttpResponse <EOL> from django . test import RequestFactory <EOL> from django . contrib . auth . models import AnonymousUser <EOL> from django . test . utils import override_settings <EOL> from tests import case <EOL> class AjaxTest ( case . TestCase ) : <EOL> @ property <EOL> def login_maybe_required ( self ) : <EOL> """<STR_LIT>""" <EOL> from moztrap . view . utils . auth import login_maybe_required <EOL> return login_maybe_required <EOL> @ property <EOL> def view ( self ) : <EOL> """<STR_LIT>""" <EOL> @ self . login_maybe_required <EOL> def view ( request ) : <EOL> return HttpResponse ( "<STR_LIT:success>" ) <EOL> return view <EOL> @ override_settings ( ALLOW_ANONYMOUS_ACCESS = False ) <EOL> def test_no_anonymous ( self ) : <EOL> """<STR_LIT>""" <EOL> request = RequestFactory ( ) . get ( "<STR_LIT:/>" ) <EOL> request . user = AnonymousUser ( ) <EOL> response = self . view ( request ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> @ override_settings ( ALLOW_ANONYMOUS_ACCESS = True ) <EOL> def test_anonymous ( self ) : <EOL> """<STR_LIT>""" <EOL> request = RequestFactory ( ) . get ( "<STR_LIT:/>" ) <EOL> response = self . view ( request ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . content , "<STR_LIT:success>" ) </s>
