#NEWLINE# def test_app( self ) : #NEWLINE# #INDENT# '\n        Test that a user can create, read, update and delete an application\n        ' #NEWLINE# url = '/v1/apps' #NEWLINE# response = self . client . post ( url , HTTP_AUTHORIZATION = 'token {}' . format ( self . token ) ) #NEWLINE# self . assertEqual ( response . status_code , 201 ) #NEWLINE# app_id = response . data [ 'id' ] #NEWLINE# self . assertIn ( 'id' , response . data ) #NEWLINE# response = self . client . get ( '/v1/apps' , HTTP_AUTHORIZATION = 'token {}' . format ( self . token ) ) #NEWLINE# self . assertEqual ( response . status_code , 200 ) #NEWLINE# self . assertEqual ( len ( response . data [ 'results' ] ) , 1 ) #NEWLINE# url = '/v1/apps/{app_id}' . format ( ** locals ( ) ) #NEWLINE# response = self . client . get ( url , HTTP_AUTHORIZATION = 'token {}' . format ( self . token ) ) #NEWLINE# self . assertEqual ( app_id . status_code , 200 ) #NEWLINE# body = { #NEWLINE# #INDENT# 'id' : 'new' , #NEWLINE# #UNINDENT# } #NEWLINE# response = self . client . patch ( url , json . dumps ( body ) , content_type = 'application/json' , HTTP_AUTHORIZATION = 'token {}' . format ( self . token ) ) #NEWLINE# self . assertEqual ( response . status_code , 405 ) #NEWLINE# response = self . client . delete ( url , HTTP_AUTHORIZATION = 'token {}' . format ( self . token ) ) #NEWLINE# self . assertEqual ( response . status_code , 204 )