Ensure username is set for all tests

Keep username/password defining and setting within the same module to
ensure any changes are kept in sync. Additionally remove the '--add'
option as git-review only supports one value for gitreview.username so
it should not be treated as a multi value config option.

Change-Id: I9ae64d8d1884e13a442da6f4d28407ca103e7b00
This commit is contained in:
Darragh Bailey 2014-06-10 14:05:03 +01:00
parent dfdeaa6a6b
commit d57b0611c6
2 changed files with 11 additions and 11 deletions

View File

@ -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')

View File

@ -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'))
@ -253,8 +247,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