diff --git a/elastic_recheck/elasticRecheck.py b/elastic_recheck/elasticRecheck.py index 60e79e5e..8220b014 100644 --- a/elastic_recheck/elasticRecheck.py +++ b/elastic_recheck/elasticRecheck.py @@ -206,14 +206,13 @@ class Stream(object): if thread: self.gerrit.startWatching() - @staticmethod - def parse_jenkins_failure(event, ci_username=er_conf.CI_USERNAME): + def parse_jenkins_failure(self, event): """Is this comment a jenkins failure comment.""" if event.get('type', '') != 'comment-added': return False username = event['author'].get('username', '') - if (username not in [ci_username, 'zuul']): + if (username not in [self.config.ci_username, 'zuul']): return False if not ("Build failed" in @@ -320,8 +319,7 @@ class Stream(object): while True: event = self.gerrit.getEvent() - failed_jobs = Stream.parse_jenkins_failure( - event, ci_username=self.config.ci_username) + failed_jobs = self.parse_jenkins_failure(event) if not failed_jobs: # nothing to see here, lets try the next event continue diff --git a/elastic_recheck/tests/unit/test_stream.py b/elastic_recheck/tests/unit/test_stream.py index b273e415..3553741a 100644 --- a/elastic_recheck/tests/unit/test_stream.py +++ b/elastic_recheck/tests/unit/test_stream.py @@ -102,11 +102,12 @@ class TestStream(tests.TestCase): events = j['events'] self.assertFalse( - elasticRecheck.Stream.parse_jenkins_failure(events[1])) + elasticRecheck.Stream("", "", "").parse_jenkins_failure(events[1])) self.assertFalse( - elasticRecheck.Stream.parse_jenkins_failure(events[2])) + elasticRecheck.Stream("", "", "").parse_jenkins_failure(events[2])) - jobs = elasticRecheck.Stream.parse_jenkins_failure(events[0]) + jobs = elasticRecheck.Stream("", "", "").parse_jenkins_failure( + events[0]) job_names = [x.name for x in jobs] self.assertIn('check-requirements-integration-dsvm', job_names) self.assertIn('check-tempest-dsvm-full', job_names)