Fixed code for buildbot 2.0.0
This commit is contained in:
parent
4426a875b5
commit
1820400e26
|
@ -17,7 +17,6 @@ from buildbot.process.results import SUCCESS
|
||||||
from buildbot.process.results import WARNINGS
|
from buildbot.process.results import WARNINGS
|
||||||
from buildbot.reporters import http
|
from buildbot.reporters import http
|
||||||
from buildbot.util import httpclientservice
|
from buildbot.util import httpclientservice
|
||||||
from buildbot.util import unicode2NativeString
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -141,11 +140,7 @@ class GiteaStatusPush(http.HttpStatusPushBase):
|
||||||
"build has no owner property for Gitea.")
|
"build has no owner property for Gitea.")
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
sha = unicode2NativeString(sha)
|
target_url = build['url']
|
||||||
state = unicode2NativeString(state)
|
|
||||||
target_url = unicode2NativeString(build['url'])
|
|
||||||
context = unicode2NativeString(context)
|
|
||||||
description = unicode2NativeString(description)
|
|
||||||
res = yield self.createStatus(
|
res = yield self.createStatus(
|
||||||
project_owner=repository_owner,
|
project_owner=repository_owner,
|
||||||
repo_name=repository_name,
|
repo_name=repository_name,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import calendar
|
|
||||||
import buildbot.www.change_hook as change_hook
|
import buildbot.www.change_hook as change_hook
|
||||||
from buildbot.test.fake.web import FakeRequest
|
from buildbot.test.fake.web import FakeRequest
|
||||||
from buildbot.test.fake.web import fakeMasterForHooks
|
from buildbot.test.fake.web import fakeMasterForHooks
|
||||||
|
@ -724,11 +723,11 @@ class TestChangeHookGiteaPush(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.changeHook = change_hook.ChangeHookResource(
|
self.changeHook = change_hook.ChangeHookResource(
|
||||||
dialects={'gitea': {}},
|
dialects={'gitea': {}},
|
||||||
master=fakeMasterForHooks())
|
master=fakeMasterForHooks(self))
|
||||||
|
|
||||||
def checkChangesFromPush(self, codebase=None):
|
def checkChangesFromPush(self, codebase=None):
|
||||||
self.assertEqual(len(self.changeHook.master.addedChanges), 2)
|
self.assertEqual(len(self.changeHook.master.data.updates.changesAdded), 2)
|
||||||
change = self.changeHook.master.addedChanges[0]
|
change = self.changeHook.master.data.updates.changesAdded[0]
|
||||||
self.assertEqual(change['repository'], 'ssh://git@git.example.com/max/webhook_test.git')
|
self.assertEqual(change['repository'], 'ssh://git@git.example.com/max/webhook_test.git')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -736,7 +735,7 @@ class TestChangeHookGiteaPush(unittest.TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
change["revision"], '9d7157cc4a137b3e1dfe92750ccfb1bbad239f99')
|
change["revision"], '9d7157cc4a137b3e1dfe92750ccfb1bbad239f99')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
calendar.timegm(change["when_timestamp"].utctimetuple()),
|
change["when_timestamp"],
|
||||||
1536063014)
|
1536063014)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
change["comments"], "TestBranch\n")
|
change["comments"], "TestBranch\n")
|
||||||
|
@ -744,7 +743,7 @@ class TestChangeHookGiteaPush(unittest.TestCase):
|
||||||
self.assertEqual(change[
|
self.assertEqual(change[
|
||||||
"revlink"],
|
"revlink"],
|
||||||
"https://git.example.com/max/webhook_test/commit/9d7157cc4a137b3e1dfe92750ccfb1bbad239f99")
|
"https://git.example.com/max/webhook_test/commit/9d7157cc4a137b3e1dfe92750ccfb1bbad239f99")
|
||||||
change = self.changeHook.master.addedChanges[1]
|
change = self.changeHook.master.data.updates.changesAdded[1]
|
||||||
self.assertEqual(change['repository'], 'ssh://git@git.example.com/max/webhook_test.git')
|
self.assertEqual(change['repository'], 'ssh://git@git.example.com/max/webhook_test.git')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -752,7 +751,7 @@ class TestChangeHookGiteaPush(unittest.TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
change["revision"], 'ad7157cc4a137b3e1dfe92750ccfb1bbad239f9a')
|
change["revision"], 'ad7157cc4a137b3e1dfe92750ccfb1bbad239f9a')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
calendar.timegm(change["when_timestamp"].utctimetuple()),
|
change["when_timestamp"],
|
||||||
1536063014)
|
1536063014)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
change["comments"], "TestBranch2\n")
|
change["comments"], "TestBranch2\n")
|
||||||
|
@ -762,8 +761,8 @@ class TestChangeHookGiteaPush(unittest.TestCase):
|
||||||
"https://git.example.com/max/webhook_test/commit/ad7157cc4a137b3e1dfe92750ccfb1bbad239f9a")
|
"https://git.example.com/max/webhook_test/commit/ad7157cc4a137b3e1dfe92750ccfb1bbad239f9a")
|
||||||
|
|
||||||
def checkChangesFromPullRequest(self, codebase=None):
|
def checkChangesFromPullRequest(self, codebase=None):
|
||||||
self.assertEqual(len(self.changeHook.master.addedChanges), 1)
|
self.assertEqual(len(self.changeHook.master.data.updates.changesAdded), 1)
|
||||||
change = self.changeHook.master.addedChanges[0]
|
change = self.changeHook.master.data.updates.changesAdded[0]
|
||||||
self.assertEqual(change['repository'], 'ssh://git@git.example.com/max/webhook_test.git')
|
self.assertEqual(change['repository'], 'ssh://git@git.example.com/max/webhook_test.git')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -771,7 +770,7 @@ class TestChangeHookGiteaPush(unittest.TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
change["revision"], '9d7157cc4a137b3e1dfe92750ccfb1bbad239f99')
|
change["revision"], '9d7157cc4a137b3e1dfe92750ccfb1bbad239f99')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
calendar.timegm(change["when_timestamp"].utctimetuple()),
|
change["when_timestamp"],
|
||||||
1536063289)
|
1536063289)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
change["comments"], "PR#1: TestPR\n\n")
|
change["comments"], "PR#1: TestPR\n\n")
|
||||||
|
@ -817,7 +816,7 @@ class TestChangeHookGiteaPush(unittest.TestCase):
|
||||||
self.request.method = b'POST'
|
self.request.method = b'POST'
|
||||||
self.request.received_headers[_HEADER_EVENT_TYPE] = b"pull_request"
|
self.request.received_headers[_HEADER_EVENT_TYPE] = b"pull_request"
|
||||||
yield self.request.test_render(self.changeHook)
|
yield self.request.test_render(self.changeHook)
|
||||||
self.assertEqual(len(self.changeHook.master.addedChanges), 0)
|
self.assertEqual(len(self.changeHook.master.data.updates.changesAdded), 0)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def testPullRequestMergedEvent(self):
|
def testPullRequestMergedEvent(self):
|
||||||
|
@ -826,18 +825,18 @@ class TestChangeHookGiteaPush(unittest.TestCase):
|
||||||
self.request.method = b'POST'
|
self.request.method = b'POST'
|
||||||
self.request.received_headers[_HEADER_EVENT_TYPE] = b"pull_request"
|
self.request.received_headers[_HEADER_EVENT_TYPE] = b"pull_request"
|
||||||
yield self.request.test_render(self.changeHook)
|
yield self.request.test_render(self.changeHook)
|
||||||
self.assertEqual(len(self.changeHook.master.addedChanges), 0)
|
self.assertEqual(len(self.changeHook.master.data.updates.changesAdded), 0)
|
||||||
|
|
||||||
|
|
||||||
class TestChangeHookGiteaPushOnlySingle(unittest.TestCase):
|
class TestChangeHookGiteaPushOnlySingle(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.changeHook = change_hook.ChangeHookResource(
|
self.changeHook = change_hook.ChangeHookResource(
|
||||||
dialects={'gitea': {"onlyIncludePushCommit": True}},
|
dialects={'gitea': {"onlyIncludePushCommit": True}},
|
||||||
master=fakeMasterForHooks())
|
master=fakeMasterForHooks(self))
|
||||||
|
|
||||||
def checkChangesFromPush(self, codebase=None):
|
def checkChangesFromPush(self, codebase=None):
|
||||||
self.assertEqual(len(self.changeHook.master.addedChanges), 1)
|
self.assertEqual(len(self.changeHook.master.data.updates.changesAdded), 1)
|
||||||
change = self.changeHook.master.addedChanges[0]
|
change = self.changeHook.master.data.updates.changesAdded[0]
|
||||||
self.assertEqual(change['repository'], 'ssh://git@git.example.com/max/webhook_test.git')
|
self.assertEqual(change['repository'], 'ssh://git@git.example.com/max/webhook_test.git')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -845,7 +844,7 @@ class TestChangeHookGiteaPushOnlySingle(unittest.TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
change["revision"], '9d7157cc4a137b3e1dfe92750ccfb1bbad239f99')
|
change["revision"], '9d7157cc4a137b3e1dfe92750ccfb1bbad239f99')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
calendar.timegm(change["when_timestamp"].utctimetuple()),
|
change["when_timestamp"],
|
||||||
1536063014)
|
1536063014)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
change["comments"], "TestBranch\n")
|
change["comments"], "TestBranch\n")
|
||||||
|
@ -868,7 +867,7 @@ class TestChangeHookGiteaSecretPhrase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.changeHook = change_hook.ChangeHookResource(
|
self.changeHook = change_hook.ChangeHookResource(
|
||||||
dialects={'gitea': {"secret": "test"}},
|
dialects={'gitea': {"secret": "test"}},
|
||||||
master=fakeMasterForHooks())
|
master=fakeMasterForHooks(self))
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def testValidSecret(self):
|
def testValidSecret(self):
|
||||||
|
@ -877,7 +876,7 @@ class TestChangeHookGiteaSecretPhrase(unittest.TestCase):
|
||||||
self.request.method = b'POST'
|
self.request.method = b'POST'
|
||||||
self.request.received_headers[_HEADER_EVENT_TYPE] = b"push"
|
self.request.received_headers[_HEADER_EVENT_TYPE] = b"push"
|
||||||
yield self.request.test_render(self.changeHook)
|
yield self.request.test_render(self.changeHook)
|
||||||
self.assertEqual(len(self.changeHook.master.addedChanges), 2)
|
self.assertEqual(len(self.changeHook.master.data.updates.changesAdded), 2)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def testInvalidSecret(self):
|
def testInvalidSecret(self):
|
||||||
|
@ -886,4 +885,4 @@ class TestChangeHookGiteaSecretPhrase(unittest.TestCase):
|
||||||
self.request.method = b'POST'
|
self.request.method = b'POST'
|
||||||
self.request.received_headers[_HEADER_EVENT_TYPE] = b"push"
|
self.request.received_headers[_HEADER_EVENT_TYPE] = b"push"
|
||||||
yield self.request.test_render(self.changeHook)
|
yield self.request.test_render(self.changeHook)
|
||||||
self.assertEqual(len(self.changeHook.master.addedChanges), 0)
|
self.assertEqual(len(self.changeHook.master.data.updates.changesAdded), 0)
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -10,7 +10,7 @@ setup(name='buildbot-gitea',
|
||||||
url='https://lab132.com',
|
url='https://lab132.com',
|
||||||
packages=['buildbot_gitea'],
|
packages=['buildbot_gitea'],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"buildbot"
|
"buildbot>=2.0.0"
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
"buildbot.webhooks": [
|
"buildbot.webhooks": [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user