desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Verify the request for creating a file on a repository.'
| def test_create_file(self):
| data = {'path': 'hello.txt', 'message': 'my commit message', 'content': 'bXkgbmV3IGZpbGUgY29udGVudHM=', 'committer': {'name': 'Scott Chacon', 'email': 'schacon@gmail.com'}}
self.instance.create_file(**data)
b64_encoded_content = b64encode(data['content']).decode('utf-8')
data.update({'content':... |
'Verify the request for creating a file on a repository.'
| def test_create_file_required_content(self):
| data = {'path': 'hello.txt', 'message': 'my commit message', 'content': 123, 'committer': {'name': 'Scott Chacon', 'email': 'schacon@gmail.com'}}
with pytest.raises(ValueError):
self.instance.create_file(**data)
|
'Verify the request to fork a repository.'
| def test_create_fork(self):
| self.instance.create_fork()
self.post_called_with(url_for('forks'))
|
'Verify the request to fork a repository to an organization.'
| def test_create_fork_to_organization(self):
| self.instance.create_fork('mattchung')
self.post_called_with(url_for('forks'), data={'organization': 'mattchung'})
|
'Verify the request to create a hook.'
| def test_create_hook(self):
| data = {'name': 'web', 'config': {'url': 'http://example.com/webhook', 'content_type': 'json'}}
self.instance.create_hook(**data)
self.post_called_with(url_for('hooks'), data={'name': 'web', 'config': {'url': 'http://example.com/webhook', 'content_type': 'json'}, 'events': ['push'], 'active': True})
|
'Test that we check the validity of a hook.'
| def test_create_hook_requires_valid_name(self):
| self.instance.create_hook(name='', config='config')
assert (self.session.post.called is False)
|
'Test that we check the validity of a hook.'
| def test_create_hook_requires_valid_config(self):
| self.instance.create_hook(name='name', config={})
assert (self.session.post.called is False)
|
'Test that we check the validity of a hook.'
| def test_create_hook_requires_valid_name_and_config(self):
| self.instance.create_hook(name='name', config='')
assert (self.session.post.called is False)
|
'Verify the request to create an issue.'
| def test_create_issue(self):
| data = {'title': 'Unit Issue', 'body': 'Fake body', 'assignee': 'sigmavirus24', 'milestone': 1, 'labels': ['bug', 'enhancement']}
self.instance.create_issue(**data)
self.post_called_with(url_for('issues'), data=data)
|
'Verify the request to create an issue with multiple assignees.'
| def test_create_issue_multiple_assignees(self):
| data = {'title': 'Unit Issue', 'body': 'Fake body', 'assignees': ['itsmemattchung', 'sigmavirus24'], 'milestone': 1, 'labels': ['bug', 'enhancement']}
self.instance.create_issue(**data)
self.post_called_with(url_for('issues'), data=data)
|
'Test that we check the validity of an issue.'
| def test_create_issue_require_valid_issue(self):
| self.instance.create_issue(title=None)
assert (self.session.post.called is False)
|
'Verify the request to create a key.'
| def test_create_key(self):
| data = {'title': 'octocat@octomac', 'key': 'ssh-rsa AAA', 'read_only': False}
self.instance.create_key(**data)
self.post_called_with(url_for('keys'), data=data)
|
'Verify the request to create a key with readonly true.'
| def test_create_key_readonly(self):
| data = {'title': 'octocat@octomac', 'key': 'ssh-rsa AAA', 'read_only': True}
self.instance.create_key(**data)
self.post_called_with(url_for('keys'), data=data)
|
'Test that we check the validity of a key.'
| def test_create_key_requires_a_valid_title(self):
| self.instance.create_key(title=None, key='ssh-rsa ...')
assert (self.session.post.called is False)
|
'Test that we check the validity of a key.'
| def test_create_key_requires_a_valid_key(self):
| self.instance.create_key(title='foo', key='')
assert (self.session.post.called is False)
|
'Test that we check the validity of a key.'
| def test_create_key_requires_a_valid_title_and_key(self):
| self.instance.create_key(title='foo', key='')
assert (self.session.post.called is False)
|
'Verify the request for creating a label.'
| def test_create_label(self):
| data = {'name': 'foo', 'color': 'fafafa'}
self.instance.create_label(**data)
self.post_called_with(url_for('labels'), data=data)
|
'Verify the request for creating a label.'
| def test_create_label_required_name(self):
| data = {'name': '', 'color': 'fafafa'}
self.instance.create_label(**data)
assert (self.session.post.called is False)
|
'Verify the request for creating a label.'
| def test_create_label_required_color(self):
| data = {'name': 'foo', 'color': ''}
self.instance.create_label(**data)
assert (self.session.post.called is False)
|
'Verify the request for creating a label.'
| def test_create_label_required_name_and_color(self):
| data = {'name': '', 'color': ''}
self.instance.create_label(**data)
assert (self.session.post.called is False)
|
'Verify the request for creating a milestone.'
| def test_create_milestone(self):
| data = {'title': 'foo'}
self.instance.create_milestone(**data)
self.post_called_with(url_for('milestones'), data=data)
|
'Verify the request for creating a milestone.'
| def test_create_milestone_accepted_state(self):
| data = {'title': 'foo', 'state': 'in_progress'}
self.instance.create_milestone(**data)
self.post_called_with(url_for('milestones'), data={'title': 'foo'})
|
'Verify the request for creating a pull request.'
| def test_create_pull_private_required_data(self):
| with helper.mock.patch.object(GitHubCore, '_remove_none') as rm_none:
data = {}
self.instance._create_pull(data)
rm_none.assert_called_once_with({})
assert (self.session.post.called is False)
|
'Verify the request for creating a pull request.'
| def test_create_pull_private(self):
| data = {'title': 'foo', 'base': 'master', 'head': 'feature_branch'}
self.instance._create_pull(data)
self.post_called_with(url_for('pulls'), data=data)
|
'Verify the request for creating a pull request.'
| def test_create_pull(self):
| data = {'title': 'foo', 'base': 'master', 'head': 'feature_branch', 'body': 'body'}
with helper.mock.patch.object(Repository, '_create_pull') as pull:
self.instance.create_pull(**data)
pull.assert_called_once_with(data)
|
'Verify the request for creating a pull request from an issue.'
| def test_create_pull_from_issue(self):
| with helper.mock.patch.object(Repository, '_create_pull') as pull:
data = {'issue': 1, 'base': 'master', 'head': 'feature_branch'}
self.instance.create_pull_from_issue(**data)
pull.assert_called_once_with(data)
|
'Verify the request for creating a pull request from an issue.'
| def test_create_pull_from_issue_required_issue_number(self):
| with helper.mock.patch.object(Repository, '_create_pull') as pull:
pull_request = self.instance.create_pull_from_issue(issue=(-1), base='master', head='feature_branch')
assert (pull.called is False)
assert (pull_request is None)
|
'Verify the request to create a reference.'
| def test_create_ref(self):
| self.instance.create_ref('refs/heads/foo', 'my-fake-sha')
self.post_called_with(url_for('git/refs'), data={'ref': 'refs/heads/foo', 'sha': 'my-fake-sha'})
|
'Test that we check the validity of a reference.'
| def test_create_ref_requires_a_reference_with_two_slashes(self):
| self.instance.create_ref('refs/heads', 'my-fake-sha')
assert (self.session.post.called is False)
|
'Test that we check the validity of a reference.'
| def test_create_ref_requires_a_reference_start_with_refs(self):
| self.instance.create_ref('my-silly-ref/foo/bar', 'my-fake-sha')
assert (self.session.post.called is False)
|
'Test that we don\'t send an empty SHA.'
| def test_create_ref_requires_a_non_None_sha(self):
| self.instance.create_ref('refs/heads/valid', None)
assert (self.session.post.called is False)
|
'Test that we don\'t send an empty SHA.'
| def test_create_ref_requires_a_truthy_sha(self):
| self.instance.create_ref('refs/heads/valid', '')
assert (self.session.post.called is False)
|
'Verify the request for creating a status on a commit.'
| def test_create_status(self):
| data = {'state': 'success', 'target_url': 'foo', 'description': 'bar', 'context': 'default'}
with helper.mock.patch.object(GitHubCore, '_remove_none') as rm_none:
self.instance.create_status(sha='fake-sha', **data)
rm_none.assert_called_once_with(data)
self.post_called_with(url_for('stat... |
'Verify the request for creating a status on a commit.'
| def test_create_status_required_sha(self):
| self.instance.create_status(sha='', state='success')
assert (self.session.post.called is False)
|
'Verify the request for creating a status on a commit.'
| def test_create_status_required_state(self):
| self.instance.create_status(sha='fake-sha', state='')
assert (self.session.post.called is False)
|
'Verify the request for creating a status on a commit.'
| def test_create_status_required_sha_and_state(self):
| self.instance.create_status(sha='', state='')
assert (self.session.post.called is False)
|
'Verify we can create an annotated tag.'
| def test_create_tag_that_is_not_lightweight(self):
| self.instance.create_tag(tag='tag-name', message='message', sha='my-sha', obj_type='commit', tagger={'name': 'Ian Cordasco', 'email': 'example@example.com', 'date': '2015-11-01T12:16:00Z'})
self.post_called_with(url_for('git/tags'), data={'tag': 'tag-name', 'message': 'message', 'object': 'my-sha', 'type': '... |
'Verify the request to create a tree.'
| def test_create_tree(self):
| self.instance.create_tree([{'foo': 'bar'}])
self.post_called_with(url_for('git/trees'), data={'tree': [{'foo': 'bar'}]})
|
'Verify the request to create a tree with a base tree.'
| def test_create_tree_with_base_tree(self):
| self.instance.create_tree([{'foo': 'bar'}], base_tree='sha')
self.post_called_with(url_for('git/trees'), data={'tree': [{'foo': 'bar'}], 'base_tree': 'sha'})
|
'Verify no request is made if tree is not a list or is None.'
| def test_create_tree_rejects_invalid_trees(self):
| self.instance.create_tree({'foo': 'bar'})
self.instance.create_tree(None)
assert (self.session.post.called is False)
|
'Verify the request for deleting a repository.'
| def test_delete(self):
| self.instance.delete()
assert (self.session.delete.called is True)
|
'Verify the request for deleting a key on the repository.'
| def test_delete_key(self):
| self.instance.delete_key(1)
self.session.delete.assert_called_once_with(url_for('keys/1'))
|
'Verify the request for deleting a key on the repository.'
| def test_delete_key_required_id(self):
| assert (self.instance.delete_key((-1)) is False)
(self.session.delete.called is False)
|
'Verify the request for deleting a subscription.'
| def test_delete_subscription(self):
| self.instance.delete_subscription()
self.session.delete.assert_called_once_with(url_for('subscription'))
|
'Verify the request made to retrieve a directory\'s contents.'
| def test_directory_contents(self):
| self.instance.directory_contents('path/to/directory')
self.session.get.assert_called_once_with(url_for('contents/path/to/directory'), params={'ref': None})
|
'Verify the request made to retrieve a directory\'s contents.'
| def test_directory_contents_with_ref(self):
| self.instance.directory_contents('path/to/directory', ref='some-sha')
self.session.get.assert_called_once_with(url_for('contents/path/to/directory'), params={'ref': 'some-sha'})
|
'Verify the request made to retrieve a deployment.'
| def test_deployment(self):
| self.instance.deployment(10)
self.session.get.assert_called_once_with(url_for('deployments/10'))
|
'Verify that a positive deployment id is required.'
| def test_deployment_requires_positive_int(self):
| self.instance.deployment((-10))
assert (self.session.get.called is False)
|
'Verify the request for editing a repository.'
| def test_edit(self):
| data = {'name': 'hello-world', 'description': 'repo description', 'homepage': 'homepage_url', 'private': True, 'has_issues': True, 'has_wiki': True, 'has_downloads': True, 'default_branch': 'develop'}
with mock.patch.object(Repository, '_update_attributes') as up_attr:
assert (self.instance.edit(**da... |
'Verify the request for editing a repository.'
| def test_edit_required_name(self):
| assert (self.instance.edit(None) is False)
assert (self.session.patch.called is False)
|
'Verify the request made to retrieve a dictionary\'s contents.'
| def test_file_contents(self):
| self.instance.file_contents('path/to/file.txt', ref='some-sha')
self.session.get.assert_called_once_with(url_for('contents/path/to/file.txt'), params={'ref': 'some-sha'})
|
'Verify the request for retrieving a git commit from a repository.'
| def test_git_commit_required_sha(self):
| self.instance.git_commit('')
assert (self.session.get.called is False)
|
'Verify the request for retrieving a git commit from a repository.'
| def test_git_commit(self):
| self.instance.git_commit('fake-sha')
self.session.get.assert_called_once_with(url_for('git/commits/fake-sha'))
|
'Verify the request for retrieving a hook on a repository.'
| def test_hook(self):
| self.instance.hook(1)
self.session.get.assert_called_once_with(url_for('hooks/1'))
|
'Verify the request for retrieving a hook on a repository.'
| def test_hook_required_hook(self):
| self.instance.hook((-1))
assert (self.session.get.called is False)
|
'Verify the request for checking if a user can be assigned issues
on a repository.'
| def test_is_assignee(self):
| self.instance.is_assignee('octocat')
self.session.get.assert_called_once_with(url_for('assignees/octocat'))
|
'Verify the request for checking if a user can be assigned issues
on a repository.'
| def test_is_assignee_required_username(self):
| assert (self.instance.is_assignee('') is False)
assert (self.session.get.called is False)
|
'Verify the request for importing an issue into a repository.'
| def test_import_issue(self):
| data = {'title': 'Foo', 'body': 'Foobar body', 'created_at': '2014-03-16T17:15:42Z', 'assignee': 'octocat', 'milestone': 1, 'closed': True, 'labels': ['easy', 'bug'], 'comments': [{'created_at': '2014-03-18T17:15:42Z', 'body': 'comment body'}]}
issue = {'issue': {'title': 'Foo', 'body': 'Foobar body', ... |
'Verify the request for retrieving an imported issue.'
| def test_imported_issue(self):
| self.instance.imported_issue(1)
self.session.get.assert_called_once_with(url_for('import/issues/1'), headers={'Accept': 'application/vnd.github.golden-comet-preview+json'})
|
'Verify the request for checking if a user is a collaborator on a
repository.'
| def test_is_collaborator_required_username(self):
| assert (self.instance.is_collaborator('') is False)
assert (self.session.get.called is False)
|
'Verify the request for checking if a user is a collaborator on a
repository.'
| def test_is_collaborator(self):
| self.instance.is_collaborator('octocat')
self.session.get.assert_called_once_with(url_for('collaborators/octocat'))
|
'Verify the request for retrieving an issue on a repository.'
| def test_issue(self):
| self.instance.issue(1)
self.session.get.assert_called_once_with(url_for('issues/1'))
|
'Verify the request for retrieving an issue on a repository.'
| def test_issue_required_number(self):
| self.instance.issue((-1))
assert (self.session.get.called is False)
|
'Test the ability to fetch a deploy key.'
| def test_key(self):
| self.instance.key(10)
self.session.get.assert_called_once_with(url_for('keys/10'))
|
'Test that a positive key id is required.'
| def test_key_requires_positive_id(self):
| self.instance.key((-10))
assert (self.session.get.called is False)
|
'Verify the request for retrieving a label on a repository.'
| def test_label(self):
| self.instance.label('bug')
self.session.get.assert_called_once_with(url_for('labels/bug'))
|
'Verify the request for retrieving a label on a repository.'
| def test_label_required_name(self):
| self.instance.label('')
assert (self.session.get.called is False)
|
'Test retrieving the most recent pages build.'
| def test_latest_pages_build(self):
| self.instance.latest_pages_build()
self.session.get.assert_called_once_with(url_for('pages/builds/latest'))
|
'Test the request for retrieving the latest release'
| def test_latest_release(self):
| self.instance.latest_release()
self.session.get.assert_called_once_with(url_for('releases/latest'))
|
'Test retrieving a specific milestone.'
| def test_milestone(self):
| self.instance.milestone(20)
self.session.get.assert_called_once_with(url_for('milestones/20'))
|
'Verify the request for marking all notifications on a repository
as read.'
| def test_mark_notifications(self):
| self.instance.mark_notifications('2012-10-09T23:39:01Z')
self.put_called_with(url_for('notifications'), data={'read': True, 'last_read_at': '2012-10-09T23:39:01Z'})
|
'Verify the request for marking all notifications on a repository
as read.'
| def test_mark_notifications_required_last_read(self):
| self.instance.mark_notifications('')
self.put_called_with(url_for('notifications'), data={'read': True})
|
'Verify the request for performing a merge on a repository.'
| def test_merge(self):
| self.instance.merge(base='develop', head='feature', message='merging now')
self.post_called_with(url_for('merges'), data={'base': 'develop', 'head': 'feature', 'commit_message': 'merging now'})
|
'Verify the request for performing a merge on a repository.'
| def test_merge_no_message(self):
| data = {'base': 'develop', 'head': 'feature'}
self.instance.merge(**data)
self.post_called_with(url_for('merges'), data=data)
|
'Test that a positive milestone id is required.'
| def test_milestone_requires_positive_id(self):
| self.instance.milestone((-1))
assert (self.session.get.called is False)
|
'Test retrieving information about a repository\'s page.'
| def test_pages(self):
| self.instance.pages()
self.session.get.assert_called_once_with(url_for('pages'))
|
'Verify that parent of repository can be retrieved.'
| def test_parent(self):
| parent = self.instance.parent
assert isinstance(parent, Repository)
|
'Verify permissions of a repository can be retrieved.'
| def test_permission(self):
| permissions = {'admin': False, 'push': False, 'pull': True}
assert (self.instance.permissions == permissions)
|
'Verify the request for retrieving a pull request.'
| def test_pull_request(self):
| self.instance.pull_request(1)
self.session.get.assert_called_once_with(url_for('pulls/1'))
|
'Verify the request for retrieving a pull request.'
| def test_pull_request_required_number(self):
| self.instance.pull_request((-1))
assert (self.session.get.called is False)
|
'Verify the request for retrieving the README.'
| def test_readme(self):
| self.instance.readme()
self.session.get.assert_called_once_with(url_for('readme'))
|
'Verify the request for retrieving a reference.'
| def test_ref(self):
| self.instance.ref('heads/develop')
self.session.get.assert_called_once_with(url_for('git/refs/heads/develop'))
|
'Verify the request for retrieving a reference.'
| def test_ref_required_ref(self):
| self.instance.ref('')
assert (self.session.get.called is False)
|
'Test the request for retrieving release by tag name'
| def test_release_from_tag(self):
| self.instance.release_from_tag('v1.0.0')
self.session.get.assert_called_once_with(url_for('releases/tags/v1.0.0'))
|
'Verify the request for removing a collaborator.'
| def test_remove_collaborator(self):
| self.instance.remove_collaborator('octocat')
self.session.delete.assert_called_once_with(url_for('collaborators/octocat'))
|
'Verify the request for removing a collaborator.'
| def test_remove_collaborator_required_username(self):
| assert (self.instance.remove_collaborator('') is False)
assert (self.session.delete.called is False)
|
'Verify that the source of the repository can be retrieved.'
| def test_source(self):
| source = self.instance.source
assert isinstance(source, Repository)
|
'Verify the request for retrieving the subscription on a repo.'
| def test_subscription(self):
| self.instance.subscription()
self.session.get.assert_called_once_with(url_for('subscription'))
|
'Verify the request for retrieving an annotated tag.'
| def test_tag(self):
| self.instance.tag('fake-sha')
self.session.get.assert_called_once_with(url_for('git/tags/fake-sha'))
|
'Verify the request for retrieving an annotated tag.'
| def test_tag_required_sha(self):
| self.instance.tag('')
assert (self.session.get.called is False)
|
'Verify the request for retrieving a tree.'
| def test_tree(self):
| self.instance.tree('fake-sha')
self.session.get.assert_called_once_with(url_for('git/trees/fake-sha'))
|
'Verify the request for retrieving a tree.'
| def test_tree_required_sha(self):
| self.instance.tree('')
assert (self.session.get.called is False)
|
'Verify instance string is formatted correctly.'
| def test_str(self):
| owner = self.instance.owner
repository = self.instance.name
assert (str(self.instance) == '{0}/{1}'.format(owner, repository))
|
'Verify the request for retrieving total commit counts.'
| def test_weekly_commit_count(self):
| self.instance.weekly_commit_count()
self.session.get.assert_called_once_with(url_for('stats/participation'))
|
'Test the ability to iterate over the assignees in a Repository.'
| def test_assignees(self):
| i = self.instance.assignees()
self.get_next(i)
self.session.get.assert_called_once_with(url_for('assignees'), params={'per_page': 100}, headers={})
|
'Test the ability to iterate over the branches in a Repository.'
| def test_branches(self):
| i = self.instance.branches()
self.get_next(i)
self.session.get.assert_called_once_with(url_for('branches'), params={'per_page': 100}, headers={'Accept': 'application/vnd.github.loki-preview+json'})
|
'Test ability to iterate over protected branches in a Repository.'
| def test_branches_protected(self):
| i = self.instance.branches(protected=True)
self.get_next(i)
self.session.get.assert_called_once_with(url_for('branches'), params={'per_page': 100, 'protected': '1'}, headers={'Accept': 'application/vnd.github.loki-preview+json'})
|
'Test the ability to iterate over the statistics in a Repository.'
| def test_code_frequency(self):
| i = self.instance.code_frequency()
self.get_next(i)
self.session.get.assert_called_once_with(url_for('stats/code_frequency'), params={'per_page': 100}, headers={})
|
'Test the ability to iterate over the collaborators on a repo.'
| def test_collaborators(self):
| i = self.instance.collaborators()
self.get_next(i)
self.session.get.assert_called_once_with(url_for('collaborators'), params={'per_page': 100}, headers={})
|
'Test the ability to iterate over the comments on a repository.'
| def test_comments(self):
| i = self.instance.comments()
self.get_next(i)
self.session.get.assert_called_once_with(url_for('comments'), 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.