| |
@@ -38,13 +38,14 @@
|
| |
def init_test_repo(self):
|
| |
tests.add_content_git_repo(self.projects[0])
|
| |
repo = pygit2.Repository(self.projects[0])
|
| |
- sha = repo.references["refs/heads/master"].peel().hex
|
| |
+ sha = repo.revparse_single("HEAD").hex
|
| |
+ sha_parent = repo.revparse_single("HEAD^").hex
|
| |
project = pagure.lib.query.get_authorized_project(self.session, "test")
|
| |
- return project, sha
|
| |
+ return project, sha, sha_parent
|
| |
|
| |
@mock.patch("pagure.hooks.default.send_fedmsg_notifications")
|
| |
def test_send_action_notification(self, fedmsg):
|
| |
- project, sha = self.init_test_repo()
|
| |
+ project, sha, _ = self.init_test_repo()
|
| |
pagure.hooks.default.send_action_notification(
|
| |
self.session,
|
| |
"tag",
|
| |
@@ -63,7 +64,7 @@
|
| |
@mock.patch("pagure.hooks.default.send_fedmsg_notifications")
|
| |
def test_send_notifications(self, fedmsg):
|
| |
oldrev = "9e5f51c951c6cab20fe81419320ed740533e2f2f"
|
| |
- project, sha = self.init_test_repo()
|
| |
+ project, sha, _ = self.init_test_repo()
|
| |
pagure.hooks.default.send_notifications(
|
| |
self.session,
|
| |
project,
|
| |
@@ -80,6 +81,31 @@
|
| |
self.assertEqual(args[2]["start_commit"], sha)
|
| |
self.assertEqual(args[2]["forced"], False)
|
| |
self.assertEqual(args[2]["old_commit"], oldrev)
|
| |
+ self.assertEqual(args[2]["authors"][0]["fullname"], "Alice Author")
|
| |
+ self.assertEqual(args[2]["authors"][0]["total_commits"], 1)
|
| |
+
|
| |
+ @mock.patch("pagure.hooks.default.send_fedmsg_notifications")
|
| |
+ def test_send_notifications_two_commits(self, fedmsg):
|
| |
+ project, sha, sha_parent = self.init_test_repo()
|
| |
+ pagure.hooks.default.send_notifications(
|
| |
+ self.session,
|
| |
+ project,
|
| |
+ self.folder,
|
| |
+ "pingou",
|
| |
+ "master",
|
| |
+ [sha, sha_parent],
|
| |
+ False,
|
| |
+ None,
|
| |
+ )
|
| |
+ (_, args, kwargs) = fedmsg.mock_calls[0]
|
| |
+ self.assertEqual(args[1], "git.receive")
|
| |
+ self.assertEqual(args[2]["repo"]["name"], "test")
|
| |
+ self.assertEqual(args[2]["start_commit"], sha_parent)
|
| |
+ self.assertEqual(args[2]["end_commit"], sha)
|
| |
+ self.assertEqual(args[2]["forced"], False)
|
| |
+ self.assertEqual(args[2]["old_commit"], None)
|
| |
+ self.assertEqual(args[2]["authors"][0]["fullname"], "Alice Author")
|
| |
+ self.assertEqual(args[2]["authors"][0]["total_commits"], 2)
|
| |
|
| |
|
| |
if __name__ == "__main__":
|
| |
Currently, Fedora Badge "Long Life to Pagure" does not function correctly. The issues it has are described at https://pagure.io/fedora-badges/pull-request/806
One of the issues can be solved by simply making Pagure's git.receive notification list commit count per author. Exactly that is added here.
The notification schema is only changed by adding a new field, which should be non breaking.