From 7b04082c7c3cf43ef48698fe80b5d9449773c9e7 Mon Sep 17 00:00:00 2001 From: Marvin Pohl Date: Sat, 9 Mar 2019 16:48:41 +0100 Subject: [PATCH] Updated senderror unittest and removed invalid array access. --- buildbot_gitea/reporter.py | 2 +- buildbot_gitea/test/test_reporter.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/buildbot_gitea/reporter.py b/buildbot_gitea/reporter.py index 4fab000..effb23f 100644 --- a/buildbot_gitea/reporter.py +++ b/buildbot_gitea/reporter.py @@ -152,7 +152,7 @@ class GiteaStatusPush(http.HttpStatusPushBase): ) if res.code not in (200, 201, 204): message = yield res.json() - message = message[0].get('message', 'unspecified error') + message = message.get('message', 'unspecified error') log.msg( 'Could not send status "{state}" for ' '{repo} at {sha}: {code} : {message}'.format( diff --git a/buildbot_gitea/test/test_reporter.py b/buildbot_gitea/test/test_reporter.py index 23916bc..68bbb8f 100644 --- a/buildbot_gitea/test/test_reporter.py +++ b/buildbot_gitea/test/test_reporter.py @@ -154,14 +154,17 @@ class TestGiteaStatusPush( json={'state': 'pending', 'target_url': 'http://localhost:8080/#builders/79/builds/0', 'description': 'Build started.', 'context': 'buildbot/Builder0'}, - content_json={'message': 'sha1 not found for branch master'}, - code=404) + content_json={ + "message": "sha1 not found: d34db33fd43db33f", + "url": "https://godoc.org/github.com/go-gitea/go-sdk/gitea" + }, + code=500) build['complete'] = False self.sp.buildStarted(("build", 20, "started"), build) self.assertLogged( "Could not send status \"pending\" for " "http://gitea/buildbot/buildbot at d34db33fd43db33f:" - " sha1 not found for branch master") + " 500 : sha1 not found: d34db33fd43db33f") @defer.inlineCallbacks def test_badchange(self):