Merge "Ensure username is set for all tests"
This commit is contained in:
commit
27c07577d6
@ -186,6 +186,9 @@ class BaseGitReviewTestCase(testtools.TestCase, GerritHelpers):
|
||||
self._run_git('remote', 'add', 'gerrit', self.project_uri)
|
||||
self.addCleanup(shutil.rmtree, self.test_dir)
|
||||
|
||||
# ensure user is configured for all tests
|
||||
self._configure_gitreview_username()
|
||||
|
||||
def attach_on_exception(self, filename):
|
||||
@self.addOnException
|
||||
def attach_file(exc_info):
|
||||
@ -258,6 +261,9 @@ class BaseGitReviewTestCase(testtools.TestCase, GerritHelpers):
|
||||
os.environ['PATH'] = self.ssh_dir + os.pathsep + os.environ['PATH']
|
||||
os.environ['GIT_SSH'] = self._dir('ssh', 'ssh')
|
||||
|
||||
def _configure_gitreview_username(self):
|
||||
self._run_git('config', 'gitreview.username', 'test_user')
|
||||
|
||||
def _pick_gerrit_port_and_dir(self):
|
||||
pid = os.getpid()
|
||||
host = '127.%s.%s.%s' % (self._test_counter, pid >> 8, pid & 255)
|
||||
@ -282,3 +288,7 @@ class HttpMixin(object):
|
||||
@property
|
||||
def project_uri(self):
|
||||
return self.project_http_uri
|
||||
|
||||
def _configure_gitreview_username(self):
|
||||
# trick to set http password
|
||||
self._run_git('config', 'gitreview.username', 'test_user:test_pass')
|
||||
|
@ -31,13 +31,9 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase):
|
||||
self.assertIn('remote: New Changes:', self._run_git_review())
|
||||
self.assertIn('Change-Id:', self._run_git('log', '-1'))
|
||||
|
||||
def _configure_gitreview_username(self):
|
||||
self._run_git('config', '--add', 'gitreview.username', 'test_user')
|
||||
|
||||
def test_git_review_s(self):
|
||||
"""Test git-review -s."""
|
||||
self._run_git('remote', 'rm', 'gerrit')
|
||||
self._configure_gitreview_username()
|
||||
self._run_git_review('-s')
|
||||
self._simple_change('test file modified', 'test commit message')
|
||||
self.assertIn('Change-Id:', self._run_git('log', '-1'))
|
||||
@ -45,7 +41,6 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase):
|
||||
def test_git_review_s_in_detached_head(self):
|
||||
"""Test git-review -s in detached HEAD state."""
|
||||
self._run_git('remote', 'rm', 'gerrit')
|
||||
self._configure_gitreview_username()
|
||||
master_sha1 = self._run_git('rev-parse', 'master')
|
||||
self._run_git('checkout', master_sha1)
|
||||
self._run_git_review('-s')
|
||||
@ -60,7 +55,6 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase):
|
||||
|
||||
# Review setup with an outdated repo
|
||||
self._run_git('remote', 'rm', 'gerrit')
|
||||
self._configure_gitreview_username()
|
||||
self._run_git_review('-s')
|
||||
self._simple_change('test file modified', 'test commit message 2')
|
||||
self.assertIn('Change-Id:', self._run_git('log', '-1'))
|
||||
@ -261,8 +255,4 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase):
|
||||
|
||||
class HttpGitReviewTestCase(tests.HttpMixin, GitReviewTestCase):
|
||||
"""Class for the git-review tests over HTTP(S)."""
|
||||
|
||||
def _configure_gitreview_username(self):
|
||||
# trick to set http password
|
||||
self._run_git('config', '--add', 'gitreview.username',
|
||||
'test_user:test_pass')
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user