Commit a8385c88 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

test_rest: Add tests for endpoint triggering a rerun

Previously untested. To make sure that maintainer can do reruns but
regular and anonymous users are forbidden to do so.
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 516ac959
......@@ -323,7 +323,13 @@ class APITest(APITestBase):
json = self.get_json(entry_point, params={f[0]: f[1]})
self.assertEqual(json['count'], f[2])
NEW_REV_URL = '/series/%(series_id)s/revisions/%(version)s/newrevision/'
GET_EVENTS_URL = '/projects/%(project_id)s/events/'
class EventTest(APITestBase):
def testSeriesNewRevisionEvent(self):
# no 'since' parameter
events = self.get_json('/projects/%(project_id)s/events/')
......@@ -353,6 +359,30 @@ class EventTest(APITestBase):
params={'since': after})
self.assertEqual(events['count'], 0)
def testRetestApiEndpointAsMaintainer(self):
events_before = self.get_json(GET_EVENTS_URL)
ret = self.post(NEW_REV_URL, user=self.maintainer)
events_after = self.get_json(GET_EVENTS_URL)
self.assertEqual(200, ret.status_code)
self.assertEqual(events_before['count'] + 1, events_after['count'])
def testRetestApiEndpointAsRegularUser(self):
events_before = self.get_json(GET_EVENTS_URL)
ret = self.post(NEW_REV_URL, user=self.user)
events_after = self.get_json(GET_EVENTS_URL)
self.assertEqual(403, ret.status_code)
self.assertEqual(events_before['count'], events_after['count'])
def testRetestApiEndpointAnonnymously(self):
events_before = self.get_json(GET_EVENTS_URL)
ret = self.post(NEW_REV_URL)
events_after = self.get_json(GET_EVENTS_URL)
self.assertEqual(403, ret.status_code)
self.assertEqual(events_before['count'], events_after['count'])
def testPullRequestEvent(self):
submitter = Person()
submitter.save()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment