Commit 427469aa authored by Jérome Perrin's avatar Jérome Perrin

test_result: Tolerate "404 References for commit not found"

When a commit is no longer reachable from a branch, gitlab API does not
allow annotating the commit.

This happens quite often when we push force in the branch after test
result started to run on this branch.

/reviewed-on !972
parent c3f38db1
......@@ -94,6 +94,14 @@ class GitlabRESTConnector(XMLObject):
"name": name
},
timeout=5)
if response.status_code == requests.codes.not_found and\
response.json()['message'] == "404 References for commit Not Found":
# It can happen that commit is not found, for example when test start
# on a commit and later this commit is no longer reachable from any
# branch. This typically happen after a new commit was push-forced to
# the tested branch.
return
response.raise_for_status()
......
......@@ -1640,3 +1640,13 @@ class TestGitlabRESTConnectorInterface(ERP5TypeTestCase):
self.test_result.start()
self.tic()
def test_commit_not_found(self):
with responses.RequestsMock() as rsps:
rsps.add(
responses.POST,
self.post_commit_status_url,
json={"message": "404 References for commit Not Found"},
status=404)
self.test_result.start()
self.tic()
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