#NEWLINE# def test_get_token( ) : #NEWLINE# #INDENT# from time import time , sleep #NEWLINE# db = SQLAlchemy ( 'sqlite:///:memory:' ) #NEWLINE# auth = authcode . Auth ( SECRET_KEY , db = db ) #NEWLINE# User = auth . User #NEWLINE# db . create_all ( ) #NEWLINE# user = User ( login = 'meh' , password = 'foobar' ) #NEWLINE# db . session . add ( user ) #NEWLINE# db . session . commit ( ) #NEWLINE# token1 = user . get_token ( ) #NEWLINE# sleep ( 1 ) #NEWLINE# token2 = user . get_token ( ) #NEWLINE# assert ( token1 != token2 ) #NEWLINE# timestamp = time ( ) #NEWLINE# token1 = user . get_token ( timestamp ) #NEWLINE# token2 = user . get_token ( user ) #NEWLINE# assert ( token1 == token2 )