<s> from django . core import mail <EOL> from etc . constants import ACCOUNT_COOKIE_SALT , ACCOUNT_COOKIE <EOL> from etc . tests import ViewsBaseTestCase , BASE_TEST_USER , BASE_TEST_PASS , NON_FB_USER <EOL> from django . core . urlresolvers import reverse <EOL> VALID_CREATE_USER_FORM_DATA = dict ( first_name = "<STR_LIT>" , last_name = "<STR_LIT>" , gender = '<STR_LIT>' , password = '<STR_LIT>' , email = '<STR_LIT>' , <EOL> birth_year = '<STR_LIT>' , fbid = '<STR_LIT>' , <EOL> fb_access_token = '<STR_LIT>' , <EOL> friends = '<STR_LIT>' , <EOL> location = '<STR_LIT>' , <EOL> location_data = '<STR_LIT>' ) <EOL> INVALID_CREATE_USER_FORM_DATA = dict ( ) <EOL> class PageTests ( ViewsBaseTestCase ) : <EOL> def test_index ( self ) : <EOL> index_url = '<STR_LIT:/>' <EOL> index_template = '<STR_LIT>' <EOL> index_template_loggedin = '<STR_LIT>' <EOL> self . basic_200_test ( index_url , index_template ) <EOL> self . login ( ) <EOL> self . basic_200_test ( index_url , index_template_loggedin ) <EOL> def test_login ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . client . cookies . get ( ACCOUNT_COOKIE , None ) , None ) <EOL> self . assertEqual ( self . client . cookies . get ( ACCOUNT_COOKIE_SALT , None ) , None ) <EOL> redirect_to = "<STR_LIT:/>" <EOL> response = self . client . post ( "<STR_LIT>" , data = { "<STR_LIT:username>" : BASE_TEST_USER , "<STR_LIT:password>" : BASE_TEST_PASS , "<STR_LIT>" : redirect_to } ) <EOL> self . assertRedirects ( response , redirect_to ) <EOL> self . assertNotEqual ( self . client . cookies . get ( ACCOUNT_COOKIE , None ) , None ) <EOL> self . assertNotEqual ( self . client . cookies . get ( ACCOUNT_COOKIE_SALT , None ) , None ) <EOL> self . assertNotEqual ( self . client . cookies [ ACCOUNT_COOKIE ] . value , "<STR_LIT>" ) <EOL> self . assertNotEqual ( self . client . cookies [ ACCOUNT_COOKIE_SALT ] . value , "<STR_LIT>" ) <EOL> self . logout ( ) <EOL> response = self . client . post ( "<STR_LIT>" , data = { "<STR_LIT:username>" : NON_FB_USER [ '<STR_LIT:email>' ] , "<STR_LIT:password>" : NON_FB_USER [ '<STR_LIT>' ] , "<STR_LIT>" : redirect_to } ) <EOL> self . assertRedirects ( response , redirect_to ) <EOL> def test_logout ( self ) : <EOL> self . login ( ) <EOL> self . assertNotEqual ( self . client . cookies . get ( ACCOUNT_COOKIE , None ) , None ) <EOL> self . assertNotEqual ( self . client . cookies . get ( ACCOUNT_COOKIE_SALT , None ) , None ) <EOL> self . assertNotEqual ( self . client . cookies [ ACCOUNT_COOKIE ] . value , "<STR_LIT>" ) <EOL> self . assertNotEqual ( self . client . cookies [ ACCOUNT_COOKIE_SALT ] . value , "<STR_LIT>" ) <EOL> self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( self . client . cookies [ ACCOUNT_COOKIE ] . value , "<STR_LIT>" ) <EOL> self . assertEqual ( self . client . cookies [ ACCOUNT_COOKIE_SALT ] . value , "<STR_LIT>" ) <EOL> def test_setup ( self ) : <EOL> setup_url = "<STR_LIT>" <EOL> setup_success_url = "<STR_LIT:/>" <EOL> setup_template = "<STR_LIT>" <EOL> self . basic_200_test ( setup_url , setup_template ) <EOL> self . form_fails_test ( setup_url , INVALID_CREATE_USER_FORM_DATA , "<STR_LIT>" , setup_template ) <EOL> response = self . client . post ( setup_url , VALID_CREATE_USER_FORM_DATA ) <EOL> self . assertRedirects ( response , setup_success_url ) <EOL> def test_discover ( self ) : <EOL> discover_url = "<STR_LIT>" <EOL> discover_template = "<STR_LIT>" <EOL> self . login_redirect_test ( discover_url ) <EOL> self . login ( ) <EOL> self . basic_200_test ( discover_url , discover_template ) <EOL> def test_settings ( self ) : <EOL> settings_url = reverse ( '<STR_LIT>' ) <EOL> settings_template = "<STR_LIT>" <EOL> self . login_redirect_test ( settings_url ) <EOL> self . login ( ) <EOL> self . basic_200_test ( settings_url , settings_template ) <EOL> def test_forgot_password ( self ) : <EOL> url = "<STR_LIT>" <EOL> template = "<STR_LIT>" <EOL> template_success = "<STR_LIT>" <EOL> self . basic_200_test ( url , template ) <EOL> response = self . client . post ( url , dict ( email = "<STR_LIT>" ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertGreater ( len ( response . content ) , <NUM_LIT:0> ) <EOL> self . assertTemplateUsed ( response , template ) <EOL> response = self . client . post ( url , dict ( email = "<STR_LIT>" ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertGreater ( len ( response . content ) , <NUM_LIT:0> ) <EOL> self . assertTemplateUsed ( response , template_success ) <EOL> self . assertEquals ( len ( mail . outbox ) , <NUM_LIT:1> ) </s>
