launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27944
[Merge] ~ilasc/launchpad:update-status-report into launchpad:master
Ioana Lasc has proposed merging ~ilasc/launchpad:update-status-report into launchpad:master.
Commit message:
Add updateStatusReport endpoint
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~ilasc/launchpad/+git/launchpad/+merge/414038
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~ilasc/launchpad:update-status-report into launchpad:master.
diff --git a/lib/lp/code/interfaces/gitrepository.py b/lib/lp/code/interfaces/gitrepository.py
index e901001..048c48b 100644
--- a/lib/lp/code/interfaces/gitrepository.py
+++ b/lib/lp/code/interfaces/gitrepository.py
@@ -903,6 +903,26 @@ class IRevisionStatusReportEdit(Interface):
:param log_data: The contents (in bytes) of the log.
"""
+ @operation_parameters(
+ title=TextLine(title=_("A short title for the report."),
+ required=False),
+ url=TextLine(title=_("The external link of the status report."),
+ required=False),
+ result_summary=TextLine(title=_("A short summary of the result."),
+ required=False),
+ result=Choice(vocabulary=RevisionStatusResult, required=False))
+ @scoped(AccessTokenScope.REPOSITORY_BUILD_STATUS.title)
+ @export_write_operation()
+ @operation_for_version("devel")
+ def updateStatusReport(title, url, result_summary, result):
+ """Updates a status report.
+
+ :param title: The name of the new report.
+ :param url: The external link of the status report.
+ :param result_summary: The description of the new report.
+ :param result: The result of the new report.
+ """
+
@exported_as_webservice_entry(as_of="beta")
class IRevisionStatusReport(IRevisionStatusReportView,
diff --git a/lib/lp/code/model/gitrepository.py b/lib/lp/code/model/gitrepository.py
index 5e2c864..dc16d17 100644
--- a/lib/lp/code/model/gitrepository.py
+++ b/lib/lp/code/model/gitrepository.py
@@ -364,6 +364,17 @@ class RevisionStatusReport(StormBase):
self.date_finished = UTC_NOW
self.result = result
+ def updateStatusReport(self, title=None, url=None,
+ result_summary=None, result=None):
+ if title:
+ self.title = title
+ if url:
+ self.url = url
+ if result_summary:
+ self.result_summary = result_summary
+ if result:
+ self.result = result
+
@implementer(IRevisionStatusReportSet)
class RevisionStatusReportSet:
diff --git a/lib/lp/code/model/tests/test_gitrepository.py b/lib/lp/code/model/tests/test_gitrepository.py
index f9be757..8d67750 100644
--- a/lib/lp/code/model/tests/test_gitrepository.py
+++ b/lib/lp/code/model/tests/test_gitrepository.py
@@ -5037,14 +5037,14 @@ class TestRevisionStatusReportWebservice(TestCaseWithFactory):
super().setUp()
self.repository = self.factory.makeGitRepository()
self.requester = self.repository.owner
- title = self.factory.getUniqueUnicode('report-title')
- commit_sha1 = hashlib.sha1(b"Some content").hexdigest()
- result_summary = "120/120 tests passed"
+ self.title = self.factory.getUniqueUnicode('report-title')
+ self.commit_sha1 = hashlib.sha1(b"Some content").hexdigest()
+ self.result_summary = "120/120 tests passed"
self.report = self.factory.makeRevisionStatusReport(
user=self.repository.owner, git_repository=self.repository,
- title=title, commit_sha1=commit_sha1,
- result_summary=result_summary,
+ title=self.title, commit_sha1=self.commit_sha1,
+ result_summary=self.result_summary,
result=RevisionStatusResult.SUCCEEDED)
self.webservice = webservice_for_person(
@@ -5083,6 +5083,17 @@ class TestRevisionStatusReportWebservice(TestCaseWithFactory):
self.assertIn(md5, md5_of_all_artifacts)
self.assertIn(filesize, filesizes_of_all_artifacts)
+ def test_updateStatusReport(self):
+ response = self.webservice.named_post(
+ self.report_url, "updateStatusReport",
+ headers=self.header,
+ title='updated-report-title')
+ self.assertEqual(200, response.status)
+ with person_logged_in(self.requester):
+ self.assertEqual(self.report.title, 'updated-report-title')
+ self.assertEqual(self.report.commit_sha1, self.commit_sha1)
+ self.assertEqual(self.report.result_summary, self.result_summary)
+
class TestGitRepositoryMacaroonIssuer(MacaroonTestMixin, TestCaseWithFactory):
"""Test GitRepository macaroon issuing and verification."""
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 7ba28f6..3198e3d 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -1860,9 +1860,11 @@ class BareLaunchpadObjectFactory(ObjectFactory):
user = git_repository.owner
if commit_sha1 is None:
commit_sha1 = hashlib.sha1(self.getUniqueBytes()).hexdigest()
+ if result_summary is None:
+ result_summary = self.getUniqueUnicode()
return getUtility(IRevisionStatusReportSet).new(
- user, title, git_repository, commit_sha1, result_summary,
- url, result)
+ user, title, git_repository, commit_sha1, url,
+ result_summary, result)
def makeRevisionStatusArtifact(self, lfa=None, report=None):
"""Create a new RevisionStatusArtifact."""