mock out lp in tests that don't really need it

launchpad lib is just largely responsible for causing problems
in tests by racing on setting up directories. When we don't need
it just mock it out.

Change-Id: Ie16019b7c6e566ad55258d14f791c1f10410c4db
This commit is contained in:
Sean Dague 2014-03-10 09:52:50 -04:00
parent 2c7eb399f5
commit ce524a6c01

View File

@ -16,29 +16,28 @@ import ConfigParser
import unittest
import yaml
import mock
from elastic_recheck import bot
# NOTE(mtreinish) Using unittest here because testtools TestCase.assertRaises
# doesn't support using it as a context manager
class TestBot(unittest.TestCase):
def setUp(self):
super(TestBot, self).setUp()
self.fake_config = ConfigParser.ConfigParser({'server_password': None})
self._set_fake_config()
self.channel_config = bot.ChannelConfig(yaml.load(
open('recheckwatchbot.yaml')))
self.recheck_watch = bot.RecheckWatch(None, self.channel_config,
self.fake_config.get('gerrit',
'user'),
self.fake_config.get(
'gerrit',
'query_file'),
self.fake_config.get('gerrit',
'host'),
self.fake_config.get('gerrit',
'key'),
with mock.patch('launchpadlib.launchpad.Launchpad'):
self.recheck_watch = bot.RecheckWatch(
None,
self.channel_config,
self.fake_config.get('gerrit', 'user'),
self.fake_config.get('gerrit', 'query_file'),
self.fake_config.get('gerrit', 'host'),
self.fake_config.get('gerrit', 'key'),
False)
def _set_fake_config(self):