| |
@@ -0,0 +1,54 @@
|
| |
+ from __future__ import unicode_literals
|
| |
+
|
| |
+ from . import WidgetTest
|
| |
+
|
| |
+
|
| |
+ class TestPagurePr(WidgetTest):
|
| |
+
|
| |
+ plugin = "pagure_pr"
|
| |
+ initial_widget_config = {
|
| |
+ "repo": "fedora-hubs",
|
| |
+ }
|
| |
+
|
| |
+ def populate(self):
|
| |
+ super(TestPagurePr, self).populate()
|
| |
+ self._add_widget_under_test()
|
| |
+
|
| |
+ def _get_should_invalidate_result(self, msg):
|
| |
+ func = self.widget.module.get_cached_functions()['GetPRs']
|
| |
+ return func(self.widget).should_invalidate(msg)
|
| |
+
|
| |
+ def test_should_invalidate_wrong_topic(self):
|
| |
+ msg = {'topic': 'hubs.widget.update.WRONG.TOPIC'}
|
| |
+ self.assertFalse(self._get_should_invalidate_result(msg))
|
| |
+
|
| |
+ def test_should_invalidate_good_match(self):
|
| |
+ msg = {
|
| |
+ 'topic': 'tests.pagure.pull-request.new',
|
| |
+ 'msg': {
|
| |
+ "project": {
|
| |
+ "name": "fedora-hubs",
|
| |
+ },
|
| |
+ },
|
| |
+ }
|
| |
+ self.assertTrue(self._get_should_invalidate_result(msg))
|
| |
+ msg = {
|
| |
+ 'topic': 'tests.pagure.pull-request.closed',
|
| |
+ 'msg': {
|
| |
+ "project": {
|
| |
+ "name": "fedora-hubs",
|
| |
+ },
|
| |
+ },
|
| |
+ }
|
| |
+ self.assertTrue(self._get_should_invalidate_result(msg))
|
| |
+
|
| |
+ def test_should_invalidate_wrong_repo(self):
|
| |
+ msg = {
|
| |
+ 'topic': 'tests.pagure.pull-request.new',
|
| |
+ 'msg': {
|
| |
+ "project": {
|
| |
+ "name": "not-fedora-hubs",
|
| |
+ },
|
| |
+ },
|
| |
+ }
|
| |
+ self.assertFalse(self._get_should_invalidate_result(msg))
|
| |
Implemented more accurate version of pagure_pr widget's should_invalidate() method