<s> from django . contrib . auth . models import User <EOL> from django . core . urlresolvers import reverse <EOL> from django . test import TestCase <EOL> from django . test . utils import override_settings <EOL> from test_project . test_accounts . models import Profile <EOL> @ override_settings ( USERPROFILES_USE_PROFILE = True , AUTH_PROFILE_MODULE = '<STR_LIT>' ) <EOL> class ViewTests ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . data = { <EOL> '<STR_LIT:username>' : '<STR_LIT>' , <EOL> '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:password>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> self . user = User . objects . create_user ( self . data [ '<STR_LIT:username>' ] , self . data [ '<STR_LIT:email>' ] , <EOL> self . data [ '<STR_LIT:password>' ] ) <EOL> Profile ( user = self . user ) . save ( ) <EOL> def tearDown ( self ) : <EOL> User . objects . get ( username = self . data [ '<STR_LIT:username>' ] ) . delete ( ) <EOL> def test_profile_view ( self ) : <EOL> self . client . login ( username = self . data [ '<STR_LIT:username>' ] , password = self . data [ '<STR_LIT:password>' ] ) <EOL> url = reverse ( '<STR_LIT>' ) <EOL> response = self . client . get ( url ) <EOL> self . assertEqual ( response . context [ '<STR_LIT:user>' ] , self . user ) <EOL> @ override_settings ( USERPROFILES_REGISTRATION_FULLNAME = True ) <EOL> def test_profile_change_fullname_enabled ( self ) : <EOL> self . client . login ( username = self . data [ '<STR_LIT:username>' ] , password = self . data [ '<STR_LIT:password>' ] ) <EOL> change_url = reverse ( '<STR_LIT>' ) <EOL> response = self . client . get ( change_url ) <EOL> self . assertTrue ( '<STR_LIT>' in response . context [ '<STR_LIT>' ] . fields and <EOL> '<STR_LIT>' in response . context [ '<STR_LIT>' ] . fields ) <EOL> self . client . post ( change_url , { '<STR_LIT>' : self . data [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : self . data [ '<STR_LIT>' ] } ) <EOL> response = self . client . get ( change_url ) <EOL> self . assertTrue ( User . objects . filter ( pk = self . user . pk , <EOL> first_name = self . data [ '<STR_LIT>' ] , last_name = self . data [ '<STR_LIT>' ] ) . exists ( ) ) <EOL> def test_profile_change_fullname_disabled ( self ) : <EOL> self . client . login ( username = self . data [ '<STR_LIT:username>' ] , password = self . data [ '<STR_LIT:password>' ] ) <EOL> change_url = reverse ( '<STR_LIT>' ) <EOL> response = self . client . get ( change_url ) <EOL> self . assertFalse ( '<STR_LIT>' in response . context [ '<STR_LIT>' ] . fields and <EOL> '<STR_LIT>' in response . context [ '<STR_LIT>' ] . fields ) <EOL> @ override_settings ( USERPROFILES_PROFILE_ALLOW_EMAIL_CHANGE = True ) <EOL> def test_profile_change_email_enabled ( self ) : <EOL> self . client . login ( username = self . data [ '<STR_LIT:username>' ] , password = self . data [ '<STR_LIT:password>' ] ) <EOL> change_url = reverse ( '<STR_LIT>' ) <EOL> response = self . client . get ( change_url ) <EOL> self . assertTrue ( '<STR_LIT:email>' in response . context [ '<STR_LIT>' ] . fields ) <EOL> self . client . post ( change_url , { '<STR_LIT:email>' : self . data [ '<STR_LIT>' ] } ) <EOL> response = self . client . get ( change_url ) <EOL> self . assertTrue ( User . objects . filter ( pk = self . user . pk , <EOL> email = self . data [ '<STR_LIT>' ] ) . exists ( ) ) </s>
