def test_redis_not_started(self): """ redis not started, the R is None """ redis.StrictRedis = minimock.Mock("redis.StrictRedis") r_conn = minimock.Mock("r_conn") r_conn.info.mock_raises = redis.ConnectionError redis.StrictRedis.mock_returns = r_conn self.assertRaises(s.redis_conn(), None)
def test_redis_has_started(self): """ redis started, R.info() shall be meaningful dict """ faked_info = {'role': 'master'} redis.StrictRedis = minimock.Mock("redis.StrictRedis") r_conn = minimock.Mock("r_conn") r_conn.info.mock_returns = faked_info redis.StrictRedis.mock_returns = r_conn self.assertEqual(s.redis_conn().info(), faked_info)