Permalink
Browse files

fedmsg.meta and test for announce command.

  • Loading branch information...
1 parent 98fa696 commit 69b899bb7265ecff16858b823ca032e27716e5e7 @ralphbean committed Dec 4, 2012
Showing with 56 additions and 0 deletions.
  1. +37 −0 fedmsg/meta/announce.py
  2. +18 −0 fedmsg/tests/test_text.py
  3. +1 −0 setup.py
View
@@ -0,0 +1,37 @@
+# This file is part of fedmsg.
+# Copyright (C) 2012 Red Hat, Inc.
+#
+# fedmsg is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# fedmsg is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with fedmsg; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Authors: Ralph Bean <rbean@redhat.com>
+#
+from fedmsg.meta.base import BaseProcessor
+
+
+class AnnounceProcessor(BaseProcessor):
+ __name__ = "announce"
+ __description__ = "Official Fedora Announcements"
+ __link__ = "http://fedoraproject.org/"
+ __docs__ = "http://fedoraproject.org/"
+ __obj__ = "Announcements"
+
+ def subtitle(self, msg, **config):
+ return msg['msg']['message']
+
+ def link(self, msg, **config):
+ return msg['msg']['link']
+
+ def usernames(self, msg, **config):
+ return set([msg['username']])
View
@@ -108,6 +108,24 @@ class TestUnhandled(Base):
}
+class TestAnnouncement(Base):
+ expected_title = "announce.announcement (unsigned)"
+ expected_subti = 'hello, world.'
+ expected_link = 'foo'
+ expected_usernames = set(['ralph'])
+
+ msg = {
+ "i": 1,
+ "timestamp": 1344352873.714926,
+ "topic": "org.fedoraproject.dev.announce.announcement",
+ "msg": {
+ "message": "hello, world.",
+ "link": "foo",
+ },
+ 'username': 'ralph',
+ }
+
+
class TestLoggerNormal(Base):
expected_title = "logger.log (unsigned)"
expected_subti = 'hello, world.'
View
@@ -135,6 +135,7 @@
# fedmsg core only provides one metadata provider.
'fedmsg.meta': [
"logger=fedmsg.meta.logger:LoggerProcessor",
+ "announce=fedmsg.meta.announce:AnnounceProcessor",
],
}
)

0 comments on commit 69b899b

Please sign in to comment.