desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Show that github3.gitignore_template proxies to GitHub.'
| def test_gitignore_template(self):
| language = 'Python'
github3.gitignore_template(language)
self.gh.gitignore_template.assert_called_once_with(language)
|
'Show that github3.gitignore_templates proxies to GitHub.'
| def test_gitignore_templates(self):
| github3.gitignore_templates()
assert (self.gh.gitignore_templates.called is True)
|
'Show that github3.issue proxies to GitHub.'
| def test_issue(self):
| github3.issue('sigmavirus24', 'github3.py', 100)
self.gh.issue.assert_called_with('sigmavirus24', 'github3.py', 100)
|
'Show that github3.login proxies to GitHub.'
| def test_login(self):
| args = ('login', 'password', None, None)
with mock.patch.object(github3.GitHub, 'login') as login:
g = github3.login(*args)
assert isinstance(g, github3.GitHub)
assert (not isinstance(g, github3.GitHubEnterprise))
login.assert_called_once_with(*args)
|
'Show that github3.markdown proxies to GitHub.'
| def test_markdown(self):
| github3.markdown('text', '', '', False)
self.gh.markdown.assert_called_once_with('text', '', '', False)
|
'Show that github3.octocat proxies to GitHub.'
| def test_octocat(self):
| github3.octocat()
self.gh.octocat.assert_called_once_with(None)
|
'Show that github3.organization proxies to GitHub.'
| def test_organization(self):
| github3.organization('orgname')
self.gh.organization.assert_called_once_with('orgname')
|
'Show that github3.organizations_with proxies to GitHub.'
| def test_organizations_with(self):
| args = ('login', (-1), None)
github3.organizations_with(*args)
self.gh.organizations_with.assert_called_with(*args)
|
'Show that github3.pull_request proxies to GitHub.'
| def test_pull_request(self):
| github3.pull_request('sigmavirus24', 'github3.py', 24)
self.gh.pull_request.assert_called_once_with('sigmavirus24', 'github3.py', 24)
|
'Show that github3.rate_limit proxies to GitHub.'
| def test_rate_limit(self):
| github3.rate_limit()
self.gh.rate_limit.assert_called_once_with()
|
'Show that github3.repository proxies to GitHub.'
| def test_repository(self):
| github3.repository('sigmavirus24', 'github3.py')
self.gh.repository.assert_called_once_with('sigmavirus24', 'github3.py')
|
'Show that github3.issues_on proxies to GitHub.'
| def test_issues_on(self):
| args = ('owner', 'repository', None, None, None, None, None, None, None, None, (-1), None)
github3.issues_on(*args)
self.gh.issues_on.assert_called_with(*args)
|
'Show that github3.repositories_by proxies to GitHub.'
| def test_repositories_by(self):
| args = ('login', None, None, None, (-1), None)
github3.repositories_by('login')
self.gh.repositories_by.assert_called_with(*args)
|
'Show that github3.starred proxies to GitHub.'
| def test_starred(self):
| github3.starred_by('login')
self.gh.starred_by.assert_called_with('login', (-1), None)
|
'Show that github3.subscriptions_for proxies to GitHub.'
| def test_subcriptions_for(self):
| github3.subscriptions_for('login')
self.gh.subscriptions_for.assert_called_with('login', (-1), None)
|
'Show that github3.user proxies to GitHub.'
| def test_user(self):
| github3.user('sigmavirus24')
self.gh.user.assert_called_once_with('sigmavirus24')
|
'Show that github3.zen proxies to GitHub.'
| def test_zen(self):
| github3.zen()
assert (self.gh.zen.called is True)
|
'Verify request to add email addresses for a user.'
| def test_add_email_addresses(self):
| self.instance.add_email_addresses(['example1@example.com', 'example2@example.com'])
self.post_called_with(url_for('user/emails'), data=['example1@example.com', 'example2@example.com'])
|
'Verify no request is sent for an empty list of addresses.'
| def test_add_email_addresses_with_empty_list(self):
| self.instance.add_email_addresses([])
assert (self.session.post.called is False)
|
'Show that a user can retrieve a specific authorization by id.'
| def test_authorization(self):
| self.instance.authorization(10)
self.session.get.assert_called_once_with(url_for('authorizations/10'))
|
'Show an authorization can be created for a user without scope.'
| def test_authorize_without_scope(self):
| self.instance.authorize('username', 'password')
self.session.temporary_basic_auth.assert_called_once_with('username', 'password')
self.post_called_with(url_for('authorizations'), data={'note': '', 'note_url': '', 'client_id': '', 'client_secret': ''})
|
'Show an authorization can be created for a user.'
| def test_authorize(self):
| self.instance.authorize('username', 'password', ['user', 'repo'])
self.session.temporary_basic_auth.assert_called_once_with('username', 'password')
self.post_called_with(url_for('authorizations'), data={'note': '', 'note_url': '', 'client_id': '', 'client_secret': '', 'scopes': ['user', 'repo']})
|
'Test an app\'s ability to check a authorization token.'
| def test_check_authorization(self):
| self.instance.set_client_id('client-id', 'client-secret')
self.instance.check_authorization('super-fake-access-token')
self.session.get.assert_called_once_with(url_for('applications/client-id/tokens/super-fake-access-token'), params={'client_id': None, 'client_secret': None}, auth=('client-id', 'client-secr... |
'Test the request to create a gist.'
| def test_create_gist(self):
| self.instance.create_gist('description', {'example.py': {'content': '# example contents'}})
self.post_called_with(url_for('gists'), data={'description': 'description', 'files': {'example.py': {'content': '# example contents'}}, 'public': True})
|
'Test the request to create a key.'
| def test_create_key(self):
| self.instance.create_key('key_name', 'key text', read_only=False)
self.post_called_with(url_for('user/keys'), data={'title': 'key_name', 'key': 'key text', 'read_only': False})
|
'Test the request to create a key with read only'
| def test_create_key_with_readonly(self):
| self.instance.create_key('key_name', 'key text', read_only=True)
self.post_called_with(url_for('user/keys'), data={'title': 'key_name', 'key': 'key text', 'read_only': True})
|
'Test that no request is made with an empty key.'
| def test_create_key_requires_a_key(self):
| self.instance.create_key('title', '')
assert (self.session.post.called is False)
|
'Test that no request is made with an empty title.'
| def test_create_key_requires_a_title(self):
| self.instance.create_key('', 'key text')
assert (self.session.post.called is False)
|
'Test the request to create a repository.'
| def test_create_repository(self):
| self.instance.create_repository('repo-name')
self.post_called_with(url_for('user/repos'), data={'name': 'repo-name', 'description': '', 'homepage': '', 'private': False, 'has_issues': True, 'has_wiki': True, 'auto_init': False, 'gitignore_template': ''})
|
'Verify the request to delete a user\'s email addresses.'
| def test_delete_email_addresses(self):
| self.instance.delete_email_addresses(['example1@example.com', 'example2@example.com'])
self.delete_called_with(url_for('user/emails'), data=['example1@example.com', 'example2@example.com'])
|
'Test the request to retrieve GitHub\'s emojis.'
| def test_emojis(self):
| self.instance.emojis()
self.session.get.assert_called_once_with(url_for('emojis'))
|
'Test the request to follow a user.'
| def test_follow(self):
| self.instance.follow('username')
self.session.put.assert_called_once_with(url_for('user/following/username'))
|
'Test that GitHub#follow requires a username.'
| def test_follow_requires_a_username(self):
| self.instance.follow(None)
assert (self.session.put.called is False)
|
'Test the request to retrieve a specific gist.'
| def test_gist(self):
| self.instance.gist(10)
self.session.get.assert_called_once_with(url_for('gists/10'))
|
'Test the request to retrieve a gitignore template.'
| def test_gitignore_template(self):
| self.instance.gitignore_template('Python')
self.session.get.assert_called_once_with(url_for('gitignore/templates/Python'))
|
'Test the request to retrieve gitignore templates.'
| def test_gitignore_templates(self):
| self.instance.gitignore_templates()
self.session.get.assert_called_once_with(url_for('gitignore/templates'))
|
'Test the request to check if the user is following a user.'
| def test_is_following(self):
| self.instance.is_following('username')
self.session.get.assert_called_once_with(url_for('user/following/username'))
|
'Test the request to check if the user starred a repository.'
| def test_is_starred(self):
| self.instance.is_starred('username', 'repository')
self.session.get.assert_called_once_with(url_for('user/starred/username/repository'))
|
'Test that GitHub#is_starred requires an owner.'
| def test_is_starred_requires_an_owner(self):
| self.instance.is_starred(None, 'repo')
assert (self.session.get.called is False)
|
'Test that GitHub#is_starred requires an repo.'
| def test_is_starred_requires_a_repo(self):
| self.instance.is_starred('username', None)
assert (self.session.get.called is False)
|
'Test the request to retrieve a single issue.'
| def test_issue(self):
| self.instance.issue('owner', 'repo', 1)
self.session.get.assert_called_once_with(url_for('repos/owner/repo/issues/1'))
|
'Test GitHub#issue requires a non-None username.'
| def test_issue_requires_username(self):
| self.instance.issue(None, 'foo', 1)
assert (self.session.get.called is False)
|
'Test GitHub#issue requires a non-None repository.'
| def test_issue_requires_repository(self):
| self.instance.issue('foo', None, 1)
assert (self.session.get.called is False)
|
'Test GitHub#issue requires positive issue id.'
| def test_issue_requires_positive_issue_id(self):
| self.instance.issue('foo', 'bar', (-1))
assert (self.session.get.called is False)
|
'Verify request for retrieving a user\'s key.'
| def test_key(self):
| self.instance.key(1)
self.session.get.assert_called_once_with(url_for('user/keys/1'))
|
'Verify request for retrieving a user\'s key.'
| def test_key_negative_id(self):
| self.instance.key((-1))
(self.session.get.called is False)
|
'Verify the request for user logging in.'
| def test_login(self):
| self.instance.login('user', 'password')
self.session.basic_auth.assert_called_once_with('user', 'password')
self.session.two_factor_auth_callback.assert_called_once_with(None)
|
'Verify the request for user logging in.'
| def test_login_with_token(self):
| token = 'OauthToken'
def _callback(x):
return x
callback = _callback
self.instance.login(token=token, two_factor_callback=callback)
self.session.token_auth.assert_called_once_with(token)
self.session.two_factor_auth_callback.assert_called_once_with(callback)
|
'Verify the request for rendering a markdown document.'
| def test_markdown(self):
| self.session.post.return_value = helper.mock.Mock(ok=True)
text = '##Hello'
mode = 'markdown'
self.instance.markdown(text=text, mode=mode)
self.post_called_with(url_for('markdown'), data={'text': text, 'mode': mode}, headers={})
|
'Verify the request for rendering a markdown document.'
| def test_markdown_raw(self):
| self.session.post.return_value = helper.mock.Mock(ok=True)
text = 'Hello'
raw = True
self.instance.markdown(text=text, raw=raw)
self.session.post.assert_called_once_with(url_for('markdown/raw'), 'Hello', headers={'content-type': 'text/plain'})
|
'Verify the request for rendering a markdown document.'
| def test_markdown_gfm(self):
| self.session.post.return_value = helper.mock.Mock(ok=True)
text = '##Hello'
mode = 'gfm'
context = 'sigmavirus24/github3.py'
self.instance.markdown(text=text, mode=mode, context=context)
self.post_called_with(url_for('markdown'), data={'text': text, 'mode': mode, 'context': context}, headers={})... |
'Test the ability to retrieve the authenticated user\'s info.'
| def test_me(self):
| self.instance.me()
self.session.get.assert_called_once_with(url_for('user'))
|
'Verify the request for returning incoming service hooks data.'
| def test_meta(self):
| self.instance.meta()
self.session.get.assert_called_once_with(url_for('meta'))
|
'Verify the request for retrieving an easter egg.'
| def test_octocat(self):
| self.session.get.return_value = helper.mock.Mock(ok=True, text='egg')
egg = self.instance.octocat(say='hello')
self.session.get.assert_called_once_with(url_for('octocat'), params={'s': 'hello'})
assert (egg == 'egg')
|
'Verify the request for retrieving an easter egg.'
| def test_octocat_response_not_ok(self):
| self.session.get.return_value = helper.mock.Mock(ok=False, text='egg')
egg = self.instance.octocat(say='hello')
assert (egg == '')
|
'Verify the request for retrieving an organization.'
| def test_organization(self):
| self.instance.organization(username='github3py')
self.session.get.assert_called_once_with(url_for('orgs/github3py'))
|
'Verify the request for creating a pubsubhubbub hook.'
| def test_pubsubhubbub(self):
| topic = ('hub.topic', 'https://github.com/octocat/hello-world/events/push')
body = [('hub.mode', 'subscribe'), topic, ('hub.callback', 'https://localhost/post')]
data = dict([(k[4:], v) for (k, v) in body])
self.instance.pubsubhubbub(**data)
self.session.post.assert_called_once_with(url_for('hub'), ... |
'Verify a valid call with invalid username does not call post.'
| def test_pubsubhubbub_invalid_username(self):
| topic = ('hub.topic', 'https://github.com/-octocat/hello-world/events/push')
body = [('hub.mode', 'subscribe'), topic, ('hub.callback', 'https://localhost/post')]
data = dict([(k[4:], v) for (k, v) in body])
self.instance.pubsubhubbub(**data)
assert (self.session.post.called is False)
|
'Verify a valid call with valid username calls post.'
| def test_pubsubhubbub_valid_username(self):
| topic = ('hub.topic', 'https://github.com/o-cto-ca-t/hello-world/events/push')
body = [('hub.mode', 'subscribe'), topic, ('hub.callback', 'https://localhost/post')]
data = dict([(k[4:], v) for (k, v) in body])
self.instance.pubsubhubbub(**data)
assert (self.session.post.called is True)
|
'Verify the request for creating a pubsubhubbub hook.'
| def test_pubsubhubbub_secret(self):
| topic = ('hub.topic', 'https://github.com/octocat/hello-world/events/push')
body = [('hub.mode', 'subscribe'), topic, ('hub.callback', 'https://localhost/post'), ('hub.secret', 'secret')]
data = dict([(k[4:], v) for (k, v) in body])
self.instance.pubsubhubbub(**data)
self.session.post.assert_called_... |
'Verify the request for creating a pubsubhubbub hook.'
| def test_pubsubhubbub_required_callback(self):
| topic = ('hub.topic', 'https://github.com/octocat/hello-world/events/push')
body = [('hub.mode', 'subscribe'), topic, ('hub.callback', '')]
data = dict([(k[4:], v) for (k, v) in body])
self.instance.pubsubhubbub(**data)
assert (self.session.post.called is False)
|
'Verify the request for creating a pubsubhubbub hook.'
| def test_pubsubhubbub_required_mode(self):
| topic = ('hub.topic', 'https://github.com/octocat/hello-world/events/push')
body = [('hub.mode', ''), topic, ('hub.callback', 'https://localhost/post')]
data = dict([(k[4:], v) for (k, v) in body])
self.instance.pubsubhubbub(**data)
assert (self.session.post.called is False)
|
'Verify the request for creating a pubsubhubbub hook.'
| def test_pubsubhubbub_required_topic(self):
| body = [('hub.mode', ''), ('hub.topic', ''), ('hub.callback', 'https://localhost/post')]
data = dict([(k[4:], v) for (k, v) in body])
self.instance.pubsubhubbub(**data)
assert (self.session.post.called is False)
|
'Verify the request for creating a pubsubhubbub hook.'
| def test_pubsubhubbub_topic_no_match(self):
| body = [('hub.mode', 'subscribe'), ('hub.topic', ''), ('hub.callback', 'https://localhost/post')]
data = dict([(k[4:], v) for (k, v) in body])
self.instance.pubsubhubbub(**data)
assert (self.session.post.called is False)
|
'Verify the request for retrieving a pull request.'
| def test_pull_request(self):
| self.instance.pull_request(owner='octocat', repository='hello-world', number=1)
self.session.get.assert_called_once_with(url_for('repos/octocat/hello-world/pulls/1'))
|
'Verify the request for retrieving a pull request.'
| def test_pull_request_negative_id(self):
| self.instance.pull_request(owner='octocat', repository='hello-world', number=(-1))
(self.session.get.called is False)
|
'Verify the GET request for a repository.'
| def test_repository(self):
| self.instance.repository('user', 'repo')
self.session.get.assert_called_once_with(url_for('repos/user/repo'), headers={'Accept': 'application/vnd.github.drax-preview+json'})
|
'Verify there is no call made for invalid repo combos.'
| def test_repository_with_invalid_repo(self):
| self.instance.repository('user', None)
assert (self.session.get.called is False)
|
'Verify there is no call made for invalid username combos.'
| def test_repository_with_invalid_user(self):
| self.instance.repository(None, 'repo')
assert (self.session.get.called is False)
|
'Verify there is no call made for invalid user/repo combos.'
| def test_repository_with_invalid_user_and_repo(self):
| self.instance.repository(None, None)
assert (self.session.get.called is False)
|
'Test the ability to retrieve a repository by its id.'
| def test_repository_with_id(self):
| self.instance.repository_with_id(10)
self.session.get.assert_called_once_with(url_for('repositories/10'))
|
'Test the ability to retrieve a repository by its id.'
| def test_repository_with_id_requires_a_positive_id(self):
| self.instance.repository_with_id((-10))
assert (self.session.get.called is False)
|
'Test the ability to retrieve a repository by its id.'
| def test_repository_with_id_accepts_a_string(self):
| self.instance.repository_with_id('10')
self.session.get.assert_called_once_with(url_for('repositories/10'))
|
'Test the ability to set client id/secret.'
| def test_set_client_id(self):
| auth = ('id000000000000000000', 'secret99999999999999')
self.instance.set_client_id(*auth)
assert (self.session.params['client_id'] == auth[0])
assert (self.session.params['client_secret'] == auth[1])
|
'Test the ability to pass two_factor_callback.'
| def test_two_factor_login(self):
| self.instance.login('username', 'password', two_factor_callback=(lambda *args: 'foo'))
|
'Test that two_factor_callback is not required.'
| def test_can_login_without_two_factor_callback(self):
| self.instance.login('username', 'password')
self.instance.login(token='token')
|
'Verify the request for unfollowing a user.'
| def test_unfollow(self):
| self.instance.unfollow('sigmavirus24')
self.session.delete.assert_called_once_with(url_for('user/following/sigmavirus24'))
|
'Verify the request for unfollowing a user.'
| def test_unfollow_required_username(self):
| self.instance.unfollow('')
(self.session.delete.called is False)
|
'Verify the request for unstarring a repository.'
| def test_unstar(self):
| self.instance.unstar('sigmavirus24', 'github3.py')
self.session.delete.assert_called_once_with(url_for('user/starred/sigmavirus24/github3.py'))
|
'Verify the request for unstarring a repository.'
| def test_unstar_requires_username(self):
| self.instance.unstar('', 'github3.py')
(self.session.delete.called is False)
|
'Verify the request for unstarring a repository.'
| def test_unstar_requires_repository(self):
| self.instance.unstar('sigmavirus24', '')
(self.session.delete.called is False)
|
'Verify the request for unstarring a repository.'
| def test_unstar_requires_username_and_repository(self):
| self.instance.unstar('', '')
(self.session.delete.called is False)
|
'Verify the request to update the authenticated user\'s profile.'
| def test_update_me(self):
| self.instance.update_me(name='New name', email='email@example.com', blog='http://blog.example.com', company='Corp', location='here')
self.patch_called_with(url_for('user'), data={'name': 'New name', 'email': 'email@example.com', 'blog': 'http://blog.example.com', 'company': 'Corp', 'location': 'here', 'hi... |
'Test that a user can retrieve information about any user.'
| def test_user(self):
| self.instance.user('username')
self.session.get.assert_called_once_with(url_for('users/username'))
|
'Test that any user\'s information can be retrieved by id.'
| def test_user_with_id(self):
| self.instance.user_with_id(10)
self.session.get.assert_called_once_with(url_for('user/10'))
|
'Test that user_with_id requires a positive parameter.'
| def test_user_with_id_requires_a_positive_id(self):
| self.instance.user_with_id((-10))
assert (self.session.get.called is False)
|
'Test that any user\'s information can be retrieved by id.'
| def test_user_with_id_accepts_a_string(self):
| self.instance.user_with_id('10')
self.session.get.assert_called_once_with(url_for('user/10'))
|
'Verify the request for starring a repository.'
| def test_star(self):
| self.instance.star('sigmavirus24', 'github3.py')
self.session.put.assert_called_once_with(url_for('user/starred/sigmavirus24/github3.py'))
|
'Verify the request for returning a quote from Zen of Github.'
| def test_zen(self):
| self.session.get.return_value = helper.mock.Mock(status_code=200, text='hello')
self.instance.zen()
self.session.get.assert_called_once_with(url_for('zen'))
|
'Show that one can iterate over all public events.'
| def test_all_events(self):
| i = self.instance.all_events()
self.get_next(i)
self.session.get.assert_called_once_with(url_for('events'), params={'per_page': 100}, headers={})
|
'Show that one can iterate over all organizations.'
| def test_all_organizations(self):
| i = self.instance.all_organizations()
self.get_next(i)
self.session.get.assert_called_once_with(url_for('organizations'), params={'per_page': 100}, headers={})
|
'Show that one can iterate over all organizations with per_page.'
| def test_all_organizations_per_page(self):
| i = self.instance.all_organizations(per_page=25)
self.get_next(i)
self.session.get.assert_called_once_with(url_for('organizations'), params={'per_page': 25}, headers={})
|
'Show that one can limit the organizations returned.'
| def test_all_organizations_since(self):
| since = 100000
i = self.instance.all_organizations(since=since)
self.get_next(i)
self.session.get.assert_called_once_with(url_for('organizations'), params={'per_page': 100, 'since': since}, headers={})
|
'Show that one can iterate over all repositories.'
| def test_all_repositories(self):
| i = self.instance.all_repositories()
self.get_next(i)
self.session.get.assert_called_once_with(url_for('repositories'), params={'per_page': 100}, headers={})
|
'Show that one can iterate over all repositories with per_page.'
| def test_all_repositories_per_page(self):
| i = self.instance.all_repositories(per_page=25)
self.get_next(i)
self.session.get.assert_called_once_with(url_for('repositories'), params={'per_page': 25}, headers={})
|
'Show that one can limit the repositories returned.'
| def test_all_repositories_since(self):
| since = 100000
i = self.instance.all_repositories(since=since)
self.get_next(i)
self.session.get.assert_called_once_with(url_for('repositories'), params={'per_page': 100, 'since': since}, headers={})
|
'Show that one can iterate over all users.'
| def test_all_users(self):
| i = self.instance.all_users()
self.get_next(i)
self.session.get.assert_called_once_with(url_for('users'), params={'per_page': 100}, headers={})
|
'Show that one can iterate over all users with per_page.'
| def test_all_users_per_page(self):
| i = self.instance.all_users(per_page=25)
self.get_next(i)
self.session.get.assert_called_once_with(url_for('users'), params={'per_page': 25}, headers={})
|
'Show that one can limit the users returned.'
| def test_all_users_since(self):
| since = 100000
i = self.instance.all_users(since=since)
self.get_next(i)
self.session.get.assert_called_once_with(url_for('users'), params={'per_page': 100, 'since': since}, headers={})
|
'Show that an authenticated user can iterate over their authorizations.'
| def test_authorizations(self):
| i = self.instance.authorizations()
self.get_next(i)
self.session.get.assert_called_once_with(url_for('authorizations'), params={'per_page': 100}, headers={})
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.