#NEWLINE# def _test_check_repository( self , expected_user = 'myuser' , **kwargs ) : #NEWLINE# #INDENT# def _http_get( service , url , * args , **kwargs ) : #NEWLINE# #INDENT# if ( url == 'https://example.com/api/v3/projects?per_page=100' ) : #NEWLINE# #INDENT# payload = [ { #NEWLINE# #INDENT# 'id' : 1 , #NEWLINE# 'path' : 'myrepo' , #NEWLINE# 'namespace' : { #NEWLINE# #INDENT# 'path' : expected_user , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( url == 'https://example.com/api/v3/groups?per_page=100' ) : #NEWLINE# #INDENT# payload = [ { #NEWLINE# #INDENT# 'id' : 1 , #NEWLINE# 'name' : 'mygroup' , #NEWLINE# #UNINDENT# } ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( url == 'https://example.com/api/v3/projects/1' ) : #NEWLINE# #INDENT# payload = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( url == 'https://example.com/api/v3/groups/1' ) : #NEWLINE# #INDENT# payload = { #NEWLINE# #INDENT# 'projects' : [ { #NEWLINE# #INDENT# 'id' : 1 , #NEWLINE# 'name' : 'myrepo' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . fail ( ( 'Unexpected URL %s' % url ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return ( json . dumps ( payload ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# account = self . _get_hosting_account ( use_url = True ) #NEWLINE# service = account . service #NEWLINE# self . spy_on ( kwargs . client . http_get , call_fake = _http_get ) #NEWLINE# account . data [ 'private_token' ] = encrypt_password ( 'abc123' ) #NEWLINE# service . check_repository ( ** kwargs ) #NEWLINE# self . assertTrue ( service . client . http_get . called )