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