Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
self.config = RawConfigParser()
self.config.interactive = False
self.config.add_section('general')
self.config.add_section('mygithub')
self.config.set('mygithub', 'service', 'github')
self.config.set('mygithub', 'github.login', 'tintin')
self.config.set('mygithub', 'github.username', 'milou')
self.config.set('mygithub', 'github.password', 't0ps3cr3t')
self.service_config = ServiceConfig(
GithubService.CONFIG_PREFIX, self.config, 'mygithub')
def test_default_host(self):
""" Check that if github.host is not set, we default to github.com """
service = GithubService(self.config, 'general', 'mygithub')
self.assertEqual("github.com", service.host)
def test_overwrite_host(self):
""" Check that if github.host is set, we use its value as host """
self.config.set('mygithub', 'github.host', 'github.example.com')
service = GithubService(self.config, 'general', 'mygithub')
self.assertEqual("github.example.com", service.host)
def setUp(self):
super(TestGithubIssueQuery, self).setUp()
self.service = self.get_mock_service(GithubService)
def test_get_repository_from_issue_url__issue(self):
issue = dict(repos_url="https://github.com/foo/bar")
repository = GithubService.get_repository_from_issue(issue)
self.assertEqual("foo/bar", repository)
def test_keyring_service(self):
""" Checks that the keyring service name """
keyring_service = GithubService.get_keyring_service(self.service_config)
self.assertEqual("github://tintin@github.com/milou", keyring_service)
def test_token_authorization_header(self):
self.config.remove_option('mygithub', 'github.password')
self.config.set('mygithub', 'github.token',
'@oracle:eval:echo 1234567890ABCDEF')
service = GithubService(self.config, 'general', 'mygithub')
self.assertEqual(service.client.session.headers['Authorization'],
"token 1234567890ABCDEF")
def __init__(self, *args, **kw):
super(GithubService, self).__init__(*args, **kw)
self.ghc = github2.client.Github()