<s> """<STR_LIT>""" <EOL> import unittest <EOL> from indico . tests . testutils . server import ServerTest <EOL> from indico . tests . mocks import LOGIN_DATA , USER <EOL> from indico . routes . auth import AuthRoute <EOL> class AuthRouteTest ( ServerTest ) : <EOL> routes = [ AuthRoute ] <EOL> def setUp ( self ) : <EOL> super ( AuthRouteTest , self ) . setUp ( ) <EOL> def test_non_authenticated ( self ) : <EOL> result = self . post ( "<STR_LIT>" , USER ) <EOL> self . assertIn ( "<STR_LIT:data>" , result ) <EOL> self . assertEqual ( "<STR_LIT>" , result [ "<STR_LIT:data>" ] ) <EOL> def test_missing_credentials ( self ) : <EOL> result = self . post ( "<STR_LIT>" , USER , { } ) <EOL> self . assertEquals ( result [ "<STR_LIT:status>" ] , <NUM_LIT> ) <EOL> def test_wrong_access_key_credentials ( self ) : <EOL> BAD_LOGIN = LOGIN_DATA . copy ( ) <EOL> BAD_LOGIN [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> result = self . post ( "<STR_LIT>" , BAD_LOGIN ) <EOL> self . assertEquals ( result [ "<STR_LIT:status>" ] , <NUM_LIT> ) <EOL> def test_authed ( self ) : <EOL> self . post ( "<STR_LIT>" , LOGIN_DATA ) <EOL> result = self . post ( "<STR_LIT>" , data = None ) <EOL> self . assertTrue ( result [ "<STR_LIT:data>" ] ) <EOL> def test_login_created ( self ) : <EOL> result = self . post ( "<STR_LIT>" , LOGIN_DATA ) <EOL> self . assertIn ( "<STR_LIT:data>" , result ) <EOL> self . assertIn ( "<STR_LIT:user>" , result [ "<STR_LIT:data>" ] ) <EOL> self . assertIn ( "<STR_LIT>" , result [ "<STR_LIT:data>" ] ) <EOL> def test_login_existing ( self ) : <EOL> result = self . post ( "<STR_LIT>" , LOGIN_DATA ) <EOL> result_again = self . post ( "<STR_LIT>" , LOGIN_DATA ) <EOL> self . assertEqual ( <EOL> result [ "<STR_LIT:data>" ] [ "<STR_LIT:user>" ] [ "<STR_LIT>" ] , <EOL> result_again [ "<STR_LIT:data>" ] [ "<STR_LIT:user>" ] [ "<STR_LIT>" ] , <EOL> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
