elastic-recheck/elastic_recheck/tests/functional/test_gerrit_comment.py
Sean Dague a176ec483b time to grow up and fit in 80 columns
elastic_recheck started off life ignoring the 80 column boundary.
We should stop that, as it's bad form. Also, I do multi column
emacs and it blows my column widths.

So fix all the E501 issues and start enforcing the rules in tox

Change-Id: Ib0a1d48d085d9b21fbc1bab75e93e9cc40d36988
2013-12-02 11:43:51 -05:00

76 lines
2.7 KiB
Python

# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import ConfigParser
import gerritlib
import testtools
from elastic_recheck import elasticRecheck
class TestGerritComment(testtools.TestCase):
def setUp(self):
super(TestGerritComment, self).setUp()
config = ConfigParser.ConfigParser({'server_password': None})
config.read('elasticRecheck.conf')
self.user = config.get('gerrit', 'user')
key = config.get('gerrit', 'key')
host = 'review-dev.openstack.org'
self.stream = elasticRecheck.Stream(self.user, host, key, thread=False)
port = 29418
self.gerrit = gerritlib.gerrit.Gerrit(host, self.user, port)
def test_bug_found(self):
bug_numbers = ['1223158']
project = 'gtest-org/test'
commit_id = '434,1'
commit = '434'
self.stream.leave_comment(project, commit_id, bug_numbers)
result = self.gerrit.query(commit, comments=True)
comments = result.get('comments')
comment = comments[-1]
self.assertIn(
"I noticed tempest failed, I think you hit bug "
"https://bugs.launchpad.net/bugs/1223158",
comment.get('message'))
def test_bugs_found(self):
bug_numbers = ['1223158', '424242']
project = 'gtest-org/test'
commit_id = '434,1'
commit = '434'
self.stream.leave_comment(project, commit_id, bug_numbers)
result = self.gerrit.query(commit, comments=True)
comments = result.get('comments')
comment = comments[-1]
self.assertIn(
"I noticed tempest failed, I think you hit bug "
"https://bugs.launchpad.net/bugs/1223158 and "
"https://bugs.launchpad.net/bugs/424242 and",
comment.get('message'))
def test_bug_not_found(self):
project = 'gtest-org/test'
commit_id = '434,1'
commit = '434'
self.stream.leave_comment(project, commit_id)
result = self.gerrit.query(commit, comments=True)
comments = result.get('comments')
comment = comments[-1]
self.assertIn(
"https://wiki.openstack.org/wiki/"
"GerritJenkinsGithub#Test_Failures",
comment.get('message'))