Allow explicit control of repository name
If the user overrides the repo_name attributed, skip using the temporary name generation. Change-Id: Ia8c80ed139b5c5987886e2c7e00d63fd1d6aaf0f
This commit is contained in:
parent
a88e25197f
commit
6866203ac7
@ -65,13 +65,15 @@ class GithubRepoFixture(GithubLoginMixin, fixtures.Fixture):
|
|||||||
|
|
||||||
def _setUp(self):
|
def _setUp(self):
|
||||||
|
|
||||||
# handle template_name missing 'XXXXX' result in it containing
|
# allow user to provide an exact name to use
|
||||||
# a single element so set suffix to '' in that case.
|
if self.repo_name is None:
|
||||||
template_parts = iter(self.name_template.split('XXXXXX'))
|
# handle template_name missing 'XXXXX' result in it containing
|
||||||
prefix = next(template_parts)
|
# a single element so set suffix to '' in that case.
|
||||||
suffix = next(template_parts, '')
|
template_parts = iter(self.name_template.split('XXXXXX'))
|
||||||
|
prefix = next(template_parts)
|
||||||
|
suffix = next(template_parts, '')
|
||||||
|
|
||||||
self.repo_name = ''.join([prefix, str(uuid.uuid4())[:8], suffix])
|
self.repo_name = ''.join([prefix, str(uuid.uuid4())[:8], suffix])
|
||||||
|
|
||||||
self.addCleanup(self._delete_repo)
|
self.addCleanup(self._delete_repo)
|
||||||
|
|
||||||
|
@ -75,3 +75,16 @@ class TestGithubRepoFixture(testtools.TestCase):
|
|||||||
gh_repo.repo_name.split('-')[-1],
|
gh_repo.repo_name.split('-')[-1],
|
||||||
testtools.matchers.MatchesRegex('[a-f0-9]{8}')
|
testtools.matchers.MatchesRegex('[a-f0-9]{8}')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@mock.patch('fixtures_git.github.GithubRepoFixture.login',
|
||||||
|
mock.Mock(return_value=mock.Mock()))
|
||||||
|
def test_tempname_exact_string(self):
|
||||||
|
|
||||||
|
name = 'my-custom-tmp'
|
||||||
|
gh_repo = gh_fixture.GithubRepoFixture('owner', 'token')
|
||||||
|
gh_repo.repo_name = name
|
||||||
|
gh_repo.setUp()
|
||||||
|
self.assertThat(
|
||||||
|
gh_repo.repo_name,
|
||||||
|
testtools.matchers.Equals(name)
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user