Skip to content
Permalink
Browse files

Add support for project.group.added and project.group.access.updated …

…for pagure msgs
  • Loading branch information...
vivekanand1101 committed Aug 11, 2016
1 parent 95722bf commit 75483d2b166fa18b43d707851a1a7a071fb42510
Showing with 155 additions and 0 deletions.
  1. +23 −0 fedmsg_meta_fedora_infrastructure/pagure.py
  2. +132 −0 fedmsg_meta_fedora_infrastructure/tests/pagure.py
@@ -282,6 +282,29 @@ def subtitle(self, msg, **config):
tmpl = self._(
'{user} edited the {fields} fields of project {project}')
return tmpl.format(user=user, project=project, fields=fields)
elif 'pagure.project.group.added' in msg['topic']:
new_group = msg['msg']['new_group']
access = msg['msg'].get('access')
if access:
tmpl = self._(
'{user} added group "{new_group}" to project {project} ' + \
'with {access} access'
)
else:
tmpl = self._(
'{user} added group "{new_group}" to project {project}'
)
return tmpl.format(
user=user, project=project, new_group=new_group, access=access)
elif 'pagure.project.group.access.updated' in msg['topic']:
new_group = msg['msg']['new_group']
new_access = msg['msg']['new_access']
tmpl = self._(
'{user} updated access of group "{new_group}" ' + \
'to {new_access} on project {project}'
)
return tmpl.format(
user=user, project=project, new_group=new_group, new_access=new_access)
elif 'pagure.project.user.added' in msg['topic']:
new_user = msg['msg']['new_user']
access = msg['msg'].get('access')
@@ -822,6 +822,138 @@ class TestProjectUserAccessUpdated(Base):
}


class LegacyTestProjectGroupAdded(Base):
""" These messages are published when a someone gave admin rights on a
project on `pagure <https://pagure.io>`_.
"""
expected_title = "pagure.project.group.added"
expected_subti = 'pingou added group "awesome" to project foo'
expected_link = "https://pagure.io/foo"
expected_icon = "https://apps.fedoraproject.org/packages/" + \
"images/icons/package_128x128.png"
expected_secondary_icon = "https://seccdn.libravatar.org/avatar/" + \
"01fe73d687f4db328da1183f2a1b5b22962ca9d9c50f0728aafeac974856311c" + \
"?s=64&d=retro"
expected_packages = set([])
expected_usernames = set(['pingou'])
expected_objects = set(['project/foo'])
msg = {
"i": 4,
"timestamp": 1427455518,
"msg_id": "2015-b3c2e568-259a-4b1f-9ecc-79493b89687a",
"topic": "io.pagure.dev.pagure.project.group.added",
"msg": {
"new_group": "awesome",
"project": {
"description": "bar",
"parent": None,
"project_docs": False,
"issue_tracker": True,
"user": {
"fullname": "Pierre-YvesChibon",
"emails": [
"pingou@fedoraproject.org"
],
"name": "pingou"
},
"date_created": "1427441537",
"id": 7,
"name": "foo"
},
"agent": "pingou"
}
}


class TestProjectGroupAdded(Base):
""" These messages are published when a someone gave some rights on a
project on `pagure <https://pagure.io>`_.
"""
expected_title = "pagure.project.group.added"
expected_subti = 'pingou added group "awesome" to project foo with admin access'
expected_link = "https://pagure.io/foo"
expected_icon = "https://apps.fedoraproject.org/packages/" + \
"images/icons/package_128x128.png"
expected_secondary_icon = "https://seccdn.libravatar.org/avatar/" + \
"01fe73d687f4db328da1183f2a1b5b22962ca9d9c50f0728aafeac974856311c" + \
"?s=64&d=retro"
expected_packages = set([])
expected_usernames = set(['pingou'])
expected_objects = set(['project/foo'])
msg = {
"i": 4,
"timestamp": 1427455518,
"msg_id": "2015-b3c2e568-259a-4b1f-9ecc-79493b89687a",
"topic": "io.pagure.dev.pagure.project.group.added",
"msg": {
"new_group": "awesome",
"access": "admin",
"project": {
"description": "bar",
"parent": None,
"project_docs": False,
"issue_tracker": True,
"user": {
"fullname": "Pierre-YvesChibon",
"emails": [
"pingou@fedoraproject.org"
],
"name": "pingou"
},
"date_created": "1427441537",
"id": 7,
"name": "foo"
},
"agent": "pingou"
}
}


class TestProjectGroupAccessUpdated(Base):
""" These messages are published when a someone updated someone's rights on a
project on `pagure <https://pagure.io>`_.
"""
expected_title = "pagure.project.group.access.updated"
expected_subti = 'pingou updated access of group "awesome" to commit ' + \
'on project foo'
expected_link = "https://pagure.io/foo"
expected_icon = "https://apps.fedoraproject.org/packages/" + \
"images/icons/package_128x128.png"
expected_secondary_icon = "https://seccdn.libravatar.org/avatar/" + \
"01fe73d687f4db328da1183f2a1b5b22962ca9d9c50f0728aafeac974856311c" + \
"?s=64&d=retro"
expected_packages = set([])
expected_usernames = set(['pingou'])
expected_objects = set(['project/foo'])
msg = {
"i": 4,
"timestamp": 1427455518,
"msg_id": "2015-b3c2e568-259a-4b1f-9ecc-79493b89687a",
"topic": "io.pagure.dev.pagure.project.group.access.updated",
"msg": {
"new_group": "awesome",
"new_access": "commit",
"project": {
"description": "bar",
"parent": None,
"project_docs": False,
"issue_tracker": True,
"user": {
"fullname": "Pierre-YvesChibon",
"emails": [
"pingou@fedoraproject.org"
],
"name": "pingou"
},
"date_created": "1427441537",
"id": 7,
"name": "foo"
},
"agent": "pingou"
}
}


class TestProjectUserAdded(Base):
""" These messages are published when a someone gave some rights on a
project on `pagure <https://pagure.io>`_.

0 comments on commit 75483d2

Please sign in to comment.
You can’t perform that action at this time.