| |
@@ -0,0 +1,54 @@
|
| |
+ from __future__ import unicode_literals
|
| |
+
|
| |
+ from . import WidgetTest
|
| |
+
|
| |
+
|
| |
+ class TestGithubIssues(WidgetTest):
|
| |
+
|
| |
+ plugin = "githubissues"
|
| |
+ initial_widget_config = {
|
| |
+ "org": "fedora-infra",
|
| |
+ "repo": "fedora-hubs",
|
| |
+ }
|
| |
+
|
| |
+ def populate(self):
|
| |
+ super(TestGithubIssues, self).populate()
|
| |
+ self._add_widget_under_test()
|
| |
+
|
| |
+ def _get_should_invalidate_result(self, msg):
|
| |
+ func = self.widget.module.get_cached_functions()['GetIssues']
|
| |
+ 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.github.issue.opened',
|
| |
+ 'msg': {
|
| |
+ 'organization': 'fedora-infra',
|
| |
+ 'repository': 'fedora-hubs',
|
| |
+ }
|
| |
+ }
|
| |
+ self.assertTrue(self._get_should_invalidate_result(msg))
|
| |
+
|
| |
+ def test_should_invalidate_wrong_org(self):
|
| |
+ msg = {
|
| |
+ 'topic': 'tests.github.issue.opened',
|
| |
+ 'msg': {
|
| |
+ 'organization': 'not_fedora_infra',
|
| |
+ 'repository': 'fedora-hubs',
|
| |
+ }
|
| |
+ }
|
| |
+ self.assertFalse(self._get_should_invalidate_result(msg))
|
| |
+
|
| |
+ def test_should_invalidate_wrong_repo(self):
|
| |
+ msg = {
|
| |
+ 'topic': 'tests.github.issue.opened',
|
| |
+ 'msg': {
|
| |
+ 'organization': 'fedora-infra',
|
| |
+ 'repository': 'not-fedora-hubs',
|
| |
+ }
|
| |
+ }
|
| |
+ self.assertFalse(self._get_should_invalidate_result(msg))
|
| |
Fixes #349 and #350