Fix arguments and add tests to autospec

Remove incorrect reference to 'self' after conversion to function from
object with method. Add some simple tests using autospecing to catch
passing the wrong number of arguments to the underlying github login
methods.

Change-Id: I8919997fca40a170fe47811a66db7964ba58a9d3
This commit is contained in:
Darragh Bailey 2018-12-18 16:12:11 +00:00
parent 701e2a1c36
commit 2f95f62904
2 changed files with 15 additions and 1 deletions

View File

@ -26,7 +26,7 @@ except ImportError:
TEST_REPO_DESC = "########## Auto-generated test repository ##########"
def _login(self, token, url=None):
def _login(token, url=None):
if url is None:
url = "https://github.com"

View File

@ -20,6 +20,20 @@ import testtools
from fixtures_git import github as gh_fixture
class TestGithubLogin(testtools.TestCase):
@mock.patch('fixtures_git.github.github.enterprise_login',
autospec=True)
def test_enterprise_login(self, mock_github_login):
"""Test that correct list of arguments passed"""
gh_fixture._login('my_api_token', url="https://github.company.com")
@mock.patch('fixtures_git.github.github.login', autospec=True)
def test_default_login(self, mock_github_login):
"""Test that correct list of arguments passed"""
gh_fixture._login('my_api_token')
class TestGithubRepoFixture(testtools.TestCase):
@mock.patch('fixtures_git.github._login',