@add_fixtures(['test_scmtools'])
    def test_post_all_repositories_not_same_local_site(self):
        local_site_1 = LocalSite.objects.create(name='local-site-1')
        local_site_2 = LocalSite.objects.create(name='local-site-2')

        for local_site in (local_site_1, local_site_2):
            local_site.admins = [self.user]
            local_site.users = [self.user]
            local_site.save()

        repositories = [
            self.create_repository(name='Repo 1', local_site=local_site_1),
            self.create_repository(name='Repo 2', local_site=local_site_2),
            self.create_repository(name='Repo 3')
        ]

        rsp = self.api_post(
            get_webhook_list_url(local_site_1),
            {
                'enabled': 0,
                'events': '*',
                'url': 'http://example.com',
                'encoding': 'application/json',
                'custom_content': '',
                'apply_to': 'custom',
                'repositories': ','.join(
                    six.text_type(repo.pk)
                    for repo in repositories
                )
            },
            expected_status=400)

        self.assertEqual(rsp['stat'], 'fail')
        self.assertTrue('err' in rsp)
        self.assertEqual(rsp['err']['code'], INVALID_FORM_DATA.code)
        self.assertEqual(rsp['err']['msg'], INVALID_FORM_DATA.msg)
        self.assertTrue('fields' in rsp)
        self.assertTrue('repositories' in rsp['fields'])
        self.assertEqual(set(rsp['fields']['repositories']),
                         set([
                             'Repository with ID %s is invalid.' % repo.pk
                             for repo in repositories[1:]
                         ]))
Testing adding a webhook with a local site adnd custom repositories
dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/webapi/tests/test_webhook.py/ResourceListTests.test_post_all_repositories_not_same_local_site