<s> """<STR_LIT>""" <EOL> from django . core . urlresolvers import reverse <EOL> from django . contrib . auth . models import AnonymousUser , Permission <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . test . utils import override_settings <EOL> from mock import patch <EOL> from open_connect . context_processors . connect_processor import connect_processor <EOL> from open_connect . media . models import Image <EOL> from open_connect . connectmessages . tests import ConnectMessageTestCase <EOL> from open_connect . connect_core . utils . basetests import ConnectTestMixin <EOL> class TestConnectProcessor ( ConnectTestMixin , ConnectMessageTestCase ) : <EOL> """<STR_LIT>""" <EOL> def create_object_patch ( self , obj , name ) : <EOL> """<STR_LIT>""" <EOL> patcher = patch . object ( obj , name ) <EOL> thing = patcher . start ( ) <EOL> self . addCleanup ( patcher . stop ) <EOL> return thing <EOL> def test_authenticated_nav ( self ) : <EOL> """<STR_LIT>""" <EOL> user = self . create_user ( ) <EOL> request = self . request_factory . get ( '<STR_LIT:/>' ) <EOL> request . user = user <EOL> response = connect_processor ( request ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:label>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT:label>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] [ <NUM_LIT:2> ] [ '<STR_LIT:label>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ <NUM_LIT:2> ] [ '<STR_LIT>' ] , reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:label>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT:label>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> reverse ( '<STR_LIT>' , args = ( user . uuid , ) ) ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ <NUM_LIT:2> ] [ '<STR_LIT:label>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ <NUM_LIT:2> ] [ '<STR_LIT>' ] , reverse ( '<STR_LIT>' ) ) <EOL> @ override_settings ( LOGIN_URL = '<STR_LIT>' ) <EOL> def test_unauthenticated_nav ( self ) : <EOL> """<STR_LIT>""" <EOL> request = self . request_factory . get ( '<STR_LIT:/>' ) <EOL> request . user = AnonymousUser ( ) <EOL> response = connect_processor ( request ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , [ ] ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:label>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_is_moderator ( self ) : <EOL> """<STR_LIT>""" <EOL> request = self . request_factory . get ( '<STR_LIT:/>' ) <EOL> request . user = self . superuser <EOL> mock_get_moderation_tasks = self . create_object_patch ( <EOL> self . request . user , '<STR_LIT>' <EOL> ) <EOL> mock_get_moderation_tasks . return_value = True <EOL> response = connect_processor ( self . request ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ - <NUM_LIT:2> ] [ '<STR_LIT:label>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ - <NUM_LIT:2> ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:label>' ] , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ - <NUM_LIT:2> ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , <EOL> reverse ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ - <NUM_LIT:2> ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT:label>' ] , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ - <NUM_LIT:2> ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> reverse ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ - <NUM_LIT:2> ] [ '<STR_LIT>' ] [ <NUM_LIT:2> ] [ '<STR_LIT:label>' ] , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ - <NUM_LIT:2> ] [ '<STR_LIT>' ] [ <NUM_LIT:2> ] [ '<STR_LIT>' ] , <EOL> reverse ( '<STR_LIT>' ) <EOL> ) <EOL> @ override_settings ( BRAND_TITLE = '<STR_LIT>' ) <EOL> def test_brand_title ( self ) : <EOL> """<STR_LIT>""" <EOL> response = connect_processor ( self . request ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_user_has_access_to_admin_gallery ( self ) : <EOL> """<STR_LIT>""" <EOL> content_type = ContentType . objects . get_for_model ( Image ) <EOL> permission = Permission . objects . get ( <EOL> content_type = content_type , codename = '<STR_LIT>' ) <EOL> self . user2 . user_permissions . add ( permission ) <EOL> request = self . request_factory . get ( '<STR_LIT:/>' ) <EOL> request . user = self . user2 <EOL> response = connect_processor ( request ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ - <NUM_LIT:2> ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:label>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> response [ '<STR_LIT>' ] [ - <NUM_LIT:2> ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , <EOL> reverse ( '<STR_LIT>' ) <EOL> ) </s>
