<s> from flask import url_for <EOL> from . . core . tests import FlaskTest <EOL> from . . ext import db <EOL> class AuthTest ( FlaskTest ) : <EOL> def test_model_mixin ( self ) : <EOL> from . models import User <EOL> self . assertTrue ( User . do_true ( ) ) <EOL> def test_users ( self ) : <EOL> from . models import User <EOL> response = self . client . post ( '<STR_LIT>' , data = dict ( ) ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> user = User ( username = '<STR_LIT:test>' , pw_hash = '<STR_LIT:test>' , email = '<STR_LIT>' ) <EOL> db . session . add ( user ) <EOL> db . session . commit ( ) <EOL> self . assertTrue ( user . updated_at ) <EOL> response = self . client . post ( '<STR_LIT>' , data = dict ( <EOL> email = '<STR_LIT>' , <EOL> action_save = True , <EOL> password = '<STR_LIT:test>' ) ) <EOL> redirect_url = url_for ( self . app . config . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertRedirects ( response , redirect_url ) <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . post ( '<STR_LIT>' , data = dict ( <EOL> username = '<STR_LIT>' , <EOL> email = '<STR_LIT>' , <EOL> action_save = True , <EOL> password = '<STR_LIT:test>' , <EOL> password_confirm = '<STR_LIT:test>' , <EOL> ) ) <EOL> redirect_url = url_for ( self . app . config . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertRedirects ( response , redirect_url ) <EOL> user = User . query . filter ( User . username == '<STR_LIT>' ) . first ( ) <EOL> self . assertEqual ( user . email , '<STR_LIT>' ) <EOL> def test_manager ( self ) : <EOL> from . models import Role , User <EOL> from . manage import create_role , create_user , add_role <EOL> create_role ( '<STR_LIT:test>' ) <EOL> role = Role . query . filter ( Role . name == '<STR_LIT:test>' ) . first ( ) <EOL> self . assertEqual ( role . name , '<STR_LIT:test>' ) <EOL> create_user ( '<STR_LIT:test>' , '<STR_LIT>' , active = True , password = '<STR_LIT>' ) <EOL> user = User . query . filter ( User . username == '<STR_LIT:test>' ) . first ( ) <EOL> add_role ( '<STR_LIT:test>' , '<STR_LIT:test>' ) <EOL> self . assertTrue ( role in user . roles ) <EOL> def test_oauth ( self ) : <EOL> from flask import url_for <EOL> if self . app . config . get ( '<STR_LIT>' ) : <EOL> self . assertTrue ( url_for ( '<STR_LIT>' ) ) <EOL> if self . app . config . get ( '<STR_LIT>' ) : <EOL> self . assertTrue ( url_for ( '<STR_LIT>' ) ) <EOL> if self . app . config . get ( '<STR_LIT>' ) : <EOL> self . assertTrue ( url_for ( '<STR_LIT>' ) ) <EOL> class TestUserMixin ( object ) : <EOL> @ staticmethod <EOL> def do_true ( ) : <EOL> return True </s>
