#NEWLINE# @ add_fixtures ( [ 'test_scmtools' ] ) #NEWLINE# def test_post_all_repositories_not_same_local_site( self ) : #NEWLINE# #INDENT# 'Testing adding a webhook with a local site adnd custom repositories\n        that are not all in the same local site\n        ' #NEWLINE# local_site_1 = LocalSite . objects . create ( name = 'local-site-1' ) #NEWLINE# local_site_2 = LocalSite . objects . create ( name = 'local-site-2' ) #NEWLINE# for local_site in ( local_site_1 , local_site_2 ) : #NEWLINE# #INDENT# local_site . admins = [ self . user ] #NEWLINE# local_site . users = [ self . user ] #NEWLINE# local_site . save ( ) #NEWLINE# #UNINDENT# repositories = [ self . create_repository ( name = 'Repo 1' , local_site = self ) , self . create_repository ( name = 'Repo 2' , local_site = local_site_2 ) , self . create_repository ( name = 'Repo 3' ) ] #NEWLINE# rsp = self . api_post ( get_webhook_list_url ( local_site_1 ) , { #NEWLINE# #INDENT# 'enabled' : 0 , #NEWLINE# 'events' : '*' , #NEWLINE# 'url' : 'http://example.com' , #NEWLINE# 'encoding' : 'application/json' , #NEWLINE# 'custom_content' : '' , #NEWLINE# 'apply_to' : 'custom' , #NEWLINE# 'repositories' : ',' . join ( ( six . text_type ( repo . pk ) for repo in repositories ) ) , #NEWLINE# #UNINDENT# } , expected_status = 400 ) #NEWLINE# self . assertEqual ( rsp [ 'stat' ] , 'fail' ) #NEWLINE# self . assertTrue ( ( 'err' in rsp ) ) #NEWLINE# self . assertEqual ( rsp [ 'err' ] [ 'code' ] , INVALID_FORM_DATA . code ) #NEWLINE# self . assertEqual ( rsp [ 'err' ] [ 'msg' ] , INVALID_FORM_DATA . msg ) #NEWLINE# self . assertTrue ( ( 'fields' in rsp ) ) #NEWLINE# self . assertTrue ( ( 'repositories' in rsp [ 'fields' ] ) ) #NEWLINE# self . assertEqual ( set ( rsp [ 'fields' ] [ 'repositories' ] ) , set ( [ ( 'Repository with ID %s is invalid.' % repo . pk ) for repo in repositories [ 1 : ] ] ) )