#NEWLINE# def test_build_hook_dockerfile( self ) : #NEWLINE# #INDENT# 'Test creating a Dockerfile build via an API Hook' #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# build = { #NEWLINE# #INDENT# 'username' : 'autotest' , #NEWLINE# 'app' : app_id , #NEWLINE# #UNINDENT# } #NEWLINE# url = '/v1/hooks/builds' . format ( ** locals ( ) ) #NEWLINE# SHA = 'ecdff91c57a0b9ab82e89634df87e293d259a3aa' #NEWLINE# DOCKERFILE = '\n        FROM busybox\n        CMD /bin/true\n        ' #NEWLINE# body = { #NEWLINE# #INDENT# 'receive_user' : 'autotest' , #NEWLINE# 'receive_repo' : app_id , #NEWLINE# 'image' : '{app_id}:v2' . format ( ** locals ( ) ) , #NEWLINE# 'sha' : SHA , #NEWLINE# 'dockerfile' : DOCKERFILE , #NEWLINE# #UNINDENT# } #NEWLINE# response = self . client . post ( url , json . dumps ( body ) , content_type = 'application/json' ) #NEWLINE# self . assertEqual ( response . status_code , 401 ) #NEWLINE# response = self . client . post ( url , json . dumps ( body ) , content_type = 'application/json' , HTTP_X_DEIS_BUILDER_AUTH = settings . BUILDER_KEY ) #NEWLINE# self . assertEqual ( response . status_code , 200 ) #NEWLINE# self . assertIn ( 'release' , response . data ) #NEWLINE# self . assertIn ( 'version' , response . data [ 'release' ] ) #NEWLINE# self . assertIn ( 'domains' , response . data ) #NEWLINE# url = '/v1/apps/{app_id}/builds' . format ( ** locals ( ) ) #NEWLINE# response = self . client . get ( url , HTTP_AUTHORIZATION = 'token {}' . format ( self . token ) ) #NEWLINE# self . assertEqual ( response . status_code , 200 ) #NEWLINE# self . assertIn ( 'results' , response . data ) #NEWLINE# build = response . data [ 'results' ] [ 0 ] #NEWLINE# self . assertEqual ( build [ 'sha' ] , SHA ) #NEWLINE# self . assertEqual ( build [ 'dockerfile' ] , DOCKERFILE ) #NEWLINE# url = '/v1/apps/{app_id}/containers/cmd' . format ( ** locals ( ) ) #NEWLINE# response = self . client . get ( url , HTTP_AUTHORIZATION = 'token {}' . format ( self . token ) ) #NEWLINE# self . assertEqual ( response . status_code , 200 ) #NEWLINE# self . assertEqual ( len ( response . data [ 'results' ] ) , 1 ) #NEWLINE# container = response . data [ 'results' ] [ 0 ] #NEWLINE# self . assertEqual ( container [ 'type' ] , 'cmd' ) #NEWLINE# self . assertEqual ( container [ 'num' ] , 1 )