#NEWLINE# def test_users( self ) : #NEWLINE# #INDENT# r = Role . query . filter_by ( name = 'User' ) . first ( ) #NEWLINE# self . assertIsNotNone ( r ) #NEWLINE# u1 = User ( email = 'john@example.com' , username = 'john' , password = 'cat' , confirmed = True , role = r ) #NEWLINE# u2 = User ( email = 'susan@example.com' , username = 'susan' , password = 'dog' , confirmed = True , role = r ) #NEWLINE# db . session . add_all ( [ u1 , u2 ] ) #NEWLINE# db . session . commit ( ) #NEWLINE# response = self . client . get ( url_for ( 'api.get_user' , id = u1 . id ) , headers = self . get_api_headers ( 'susan@example.com' , 'dog' ) ) #NEWLINE# self . assertTrue ( ( response . status_code == 200 ) ) #NEWLINE# json_response = json . loads ( response . data . decode ( 'utf-8' ) ) #NEWLINE# self . assertTrue ( ( json_response [ 'username' ] == 'john' ) ) #NEWLINE# response = self . client . get ( url_for ( 'api.get_user' , id = self . id ) , headers = self . get_api_headers ( 'susan@example.com' , 'dog' ) ) #NEWLINE# self . assertTrue ( ( response . status_code == 200 ) ) #NEWLINE# json_response = json . loads ( response . data . decode ( 'utf-8' ) ) #NEWLINE# self . assertTrue ( ( json_response [ 'username' ] == 'susan' ) )