Upgrade to hacking 0.10.x

Fix up issues detected by new version of hacking

Change-Id: Ie12b9f5ccaa1ce5f49ee6bf35d3275bc9dbcbc15
This commit is contained in:
Joe Gordon 2015-04-30 16:59:20 -07:00
parent 8ff5575c5e
commit 2b97c0d156
6 changed files with 22 additions and 17 deletions

View File

@ -64,6 +64,10 @@ except Exception:
pid_file_module = daemon.pidfile
class ElasticRecheckException(Exception):
pass
class RecheckWatchBot(irc.bot.SingleServerIRCBot):
def __init__(self, channels, nickname, password, server, port=6667,
server_password=None):
@ -184,7 +188,7 @@ class RecheckWatch(threading.Thread):
if channel in self.channel_config.events['negative']:
self.new_error(channel, event)
else:
raise Exception('No event or msg specified')
raise ElasticRecheckException('No event or msg specified')
def run(self):
# Import here because it needs to happen after daemonization
@ -276,9 +280,11 @@ def _main(args, config):
if fp:
fp = os.path.expanduser(fp)
if not os.path.exists(fp):
raise Exception("Unable to read layout config file at %s" % fp)
raise ElasticRecheckException(
"Unable to read layout config file at %s" % fp)
else:
raise Exception("Channel Config must be specified in config file.")
raise ElasticRecheckException(
"Channel Config must be specified in config file.")
channel_config = ChannelConfig(yaml.load(open(fp)))
msgs = MessageConfig(yaml.load(open(fp)))

View File

@ -113,7 +113,7 @@ class FailEvent(object):
self.project = event['change']['project']
self.url = event['change']['url']
self.comment = event["comment"]
#TODO(jogo) make FailEvent generate the jobs
# TODO(jogo): make FailEvent generate the jobs
self.failed_jobs = failed_jobs
def is_openstack_project(self):
@ -253,8 +253,8 @@ class Stream(object):
for i in range(NUMBER_OF_RETRIES):
try:
for job in event.failed_jobs:
#TODO(jogo) if there are three failed jobs and only the
#last one isn't ready we don't need to keep rechecking
# TODO(jogo): if there are three failed jobs and only the
# last one isn't ready we don't need to keep rechecking
# the first two
self._job_console_uploaded(
event.change, event.rev, job.name,
@ -324,7 +324,7 @@ class Stream(object):
self.log.info("Looking for failures in %d,%d on %s" %
(fevent.change, fevent.rev,
", ".join(fevent.failed_job_names())))
", ".join(fevent.failed_job_names())))
if self._does_es_have_data(fevent):
return fevent
@ -346,7 +346,7 @@ class Stream(object):
self.gerrit.review(event.project, event.name(), msg)
class Classifier():
class Classifier(object):
"""Classify failed tempest-devstack jobs based.
Given a change and revision, query logstash with a list of known queries
@ -381,7 +381,7 @@ class Classifier():
build_short_uuid, recent=False):
"""Returns either empty list or list with matched bugs."""
self.log.debug("Entering classify")
#Reload each time
# Reload each time
self.queries = loader.load(self.queries_dir)
bug_matches = []
for x in self.queries:

View File

@ -63,7 +63,7 @@ class TestBot(unittest.TestCase):
def test_read_channel_config_not_specified(self):
self.fake_config.set('ircbot', 'channel_config', None)
with self.assertRaises(Exception) as exc:
with self.assertRaises(bot.ElasticRecheckException) as exc:
bot._main([], self.fake_config)
raised_exc = exc.exception
self.assertEqual(str(raised_exc), "Channel Config must be specified "
@ -71,14 +71,14 @@ class TestBot(unittest.TestCase):
def test_read_channel_config_invalid_path(self):
self.fake_config.set('ircbot', 'channel_config', 'fake_path.yaml')
with self.assertRaises(Exception) as exc:
with self.assertRaises(bot.ElasticRecheckException) as exc:
bot._main([], self.fake_config)
raised_exc = exc.exception
error_msg = "Unable to read layout config file at fake_path.yaml"
self.assertEqual(str(raised_exc), error_msg)
def test__read_no_event_no_msg(self):
with self.assertRaises(Exception) as exc:
with self.assertRaises(bot.ElasticRecheckException) as exc:
self.recheck_watch._read()
raised_exc = exc.exception
error_msg = 'No event or msg specified'

View File

@ -120,8 +120,7 @@ class MockDatetimeYesterday(datetime.datetime):
@mock.patch.object(pyelasticsearch.ElasticSearch, 'search', return_value={})
class TestSearchEngine(tests.TestCase):
"""Tests that the elastic search API is called correctly.
"""
"""Tests that the elastic search API is called correctly."""
def setUp(self):
super(TestSearchEngine, self).setUp()

View File

@ -1,4 +1,4 @@
hacking>=0.5.6,<0.8
hacking>=0.10.0,<0.11
coverage>=3.6
discover

View File

@ -32,11 +32,11 @@ commands = python setup.py testr --coverage --coverage-package-name='elastic_rec
commands = python elastic_recheck/bot.py -f -n --noirc elasticRecheck.conf
[flake8]
# H803 Skipped on purpose
# H233 Skipped because don't support python3 yet
# E125 Skipped because it's an overreach (and anti-emacs)
# E123 Skipped because it decreases clarity in many cases
ignore = E123,E125,H803
ignore = E123,E125,H233
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
[testenv:docs]