Convert over to notifications system. Note this is incomplete
This commit is contained in:
parent
de8e898ad0
commit
8d7493cb86
17 changed files with 432 additions and 166 deletions
|
@ -20,7 +20,7 @@ from endpoints.api.robot import UserRobotList, OrgRobot, OrgRobotList, UserRobot
|
|||
from endpoints.api.trigger import (BuildTriggerActivate, BuildTriggerSources, BuildTriggerSubdirs,
|
||||
TriggerBuildList, ActivateBuildTrigger, BuildTrigger,
|
||||
BuildTriggerList, BuildTriggerAnalyze)
|
||||
from endpoints.api.webhook import Webhook, WebhookList
|
||||
from endpoints.api.repositorynotification import RepositoryNotification, RepositoryNotificationList
|
||||
from endpoints.api.user import (PrivateRepositories, ConvertToOrganization, Signout, Signin, User,
|
||||
UserAuthorizationList, UserAuthorization)
|
||||
|
||||
|
@ -1073,41 +1073,44 @@ class TestRequestRepoBuild(ApiTestCase):
|
|||
|
||||
|
||||
|
||||
class TestWebhooks(ApiTestCase):
|
||||
class TestRepositoryNotifications(ApiTestCase):
|
||||
def test_webhooks(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
# Add a webhook.
|
||||
json = self.postJsonResponse(WebhookList,
|
||||
# Add a notification.
|
||||
json = self.postJsonResponse(RepositoryNotificationList,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/simple'),
|
||||
data=dict(url='http://example.com'),
|
||||
data=dict(config={'url': 'http://example.com'}, event='repo_push', method='webhook'),
|
||||
expected_code=201)
|
||||
|
||||
self.assertEquals('http://example.com', json['parameters']['url'])
|
||||
wid = json['public_id']
|
||||
self.assertEquals('repo_push', json['event'])
|
||||
self.assertEquals('webhook', json['method'])
|
||||
self.assertEquals('http://example.com', json['config']['url'])
|
||||
wid = json['uuid']
|
||||
|
||||
# Get the webhook.
|
||||
json = self.getJsonResponse(Webhook,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/simple', public_id=wid))
|
||||
# Get the notification.
|
||||
json = self.getJsonResponse(RepositoryNotification,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/simple', uuid=wid))
|
||||
|
||||
self.assertEquals(wid, json['public_id'])
|
||||
self.assertEquals('http://example.com', json['parameters']['url'])
|
||||
self.assertEquals(wid, json['uuid'])
|
||||
self.assertEquals('repo_push', json['event'])
|
||||
self.assertEquals('webhook', json['method'])
|
||||
|
||||
# Verify the webhook is listed.
|
||||
json = self.getJsonResponse(WebhookList,
|
||||
# Verify the notification is listed.
|
||||
json = self.getJsonResponse(RepositoryNotificationList,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/simple'))
|
||||
|
||||
ids = [w['public_id'] for w in json['webhooks']]
|
||||
ids = [w['uuid'] for w in json['notifications']]
|
||||
assert wid in ids
|
||||
|
||||
# Delete the webhook.
|
||||
self.deleteResponse(Webhook,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/simple', public_id=wid),
|
||||
# Delete the notification.
|
||||
self.deleteResponse(RepositoryNotification,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/simple', uuid=wid),
|
||||
expected_code=204)
|
||||
|
||||
# Verify the webhook is gone.
|
||||
self.getResponse(Webhook,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/simple', public_id=wid),
|
||||
# Verify the notification is gone.
|
||||
self.getResponse(RepositoryNotification,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/simple', uuid=wid),
|
||||
expected_code=404)
|
||||
|
||||
|
||||
|
|
Reference in a new issue