Drop Mixin class in favour of function
Change-Id: Id5622edb5d4209e81407786de5a9d7abe2b7b5e2
This commit is contained in:
parent
a47c606b3e
commit
f62448af84
|
@ -28,20 +28,18 @@ except ImportError:
|
|||
TEST_REPO_DESC = "########## Auto-generated test repository ##########"
|
||||
|
||||
|
||||
class GithubLoginMixin(object):
|
||||
def _login(self, token, url=None):
|
||||
|
||||
def login(self, token, url=None):
|
||||
if url is None:
|
||||
url = "https://github.com"
|
||||
|
||||
if url is None:
|
||||
url = "https://github.com"
|
||||
|
||||
if parse.urlparse(url).netloc == "github.com":
|
||||
return github.login(token=token)
|
||||
else:
|
||||
return github.enterprise_login(token=token, url=url)
|
||||
if parse.urlparse(url).netloc == "github.com":
|
||||
return github.login(token=token)
|
||||
else:
|
||||
return github.enterprise_login(token=token, url=url)
|
||||
|
||||
|
||||
class GithubRepoFixture(GithubLoginMixin, fixtures.Fixture):
|
||||
class GithubRepoFixture(fixtures.Fixture):
|
||||
"""
|
||||
Fixture to create a new repo in GitHub and remove once finished.
|
||||
"""
|
||||
|
@ -58,8 +56,7 @@ class GithubRepoFixture(GithubLoginMixin, fixtures.Fixture):
|
|||
self.repo = None
|
||||
self.repo_name = None
|
||||
|
||||
# use GithubLoginMixin
|
||||
self.github = self.login(token, url)
|
||||
self.github = _login(token, url)
|
||||
|
||||
# try an auth'ed request to make sure we have a valid token
|
||||
# note this requires the token to have read on user
|
||||
|
@ -95,7 +92,7 @@ class GithubRepoFixture(GithubLoginMixin, fixtures.Fixture):
|
|||
repo.delete()
|
||||
|
||||
|
||||
class GithubForkedRepoFixture(GithubLoginMixin, fixtures.Fixture):
|
||||
class GithubForkedRepoFixture(fixtures.Fixture):
|
||||
"""
|
||||
Fixture to create and delete a fork of the given repo in the
|
||||
default GitHub org of the token user
|
||||
|
@ -108,8 +105,7 @@ class GithubForkedRepoFixture(GithubLoginMixin, fixtures.Fixture):
|
|||
|
||||
self.repo = None
|
||||
|
||||
# use GithubLoginMixin
|
||||
self.github = self.login(token, url)
|
||||
self.github = _login(token, url)
|
||||
|
||||
# try an auth'ed request to make sure we have a valid token
|
||||
# note this requires the token to have read on user
|
||||
|
|
|
@ -22,7 +22,7 @@ from fixtures_git import github as gh_fixture
|
|||
|
||||
class TestGithubRepoFixture(testtools.TestCase):
|
||||
|
||||
@mock.patch('fixtures_git.github.GithubRepoFixture.login',
|
||||
@mock.patch('fixtures_git.github._login',
|
||||
mock.Mock(return_value=mock.Mock()))
|
||||
def test_tempname_default(self):
|
||||
|
||||
|
@ -37,7 +37,7 @@ class TestGithubRepoFixture(testtools.TestCase):
|
|||
testtools.matchers.NotEquals('workflow-test-')
|
||||
)
|
||||
|
||||
@mock.patch('fixtures_git.github.GithubRepoFixture.login',
|
||||
@mock.patch('fixtures_git.github._login',
|
||||
mock.Mock(return_value=mock.Mock()))
|
||||
def test_tempname_custom(self):
|
||||
|
||||
|
@ -54,7 +54,7 @@ class TestGithubRepoFixture(testtools.TestCase):
|
|||
testtools.matchers.EndsWith(template.split('XXXXXX')[1])
|
||||
)
|
||||
|
||||
@mock.patch('fixtures_git.github.GithubRepoFixture.login',
|
||||
@mock.patch('fixtures_git.github._login',
|
||||
mock.Mock(return_value=mock.Mock()))
|
||||
def test_tempname_no_suffix_in_template(self):
|
||||
|
||||
|
|
Loading…
Reference in New Issue