desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Test the ability to iterate over commit activity on a repo.'
def test_commit_activity(self):
i = self.instance.commit_activity() self.get_next(i) self.session.get.assert_called_once_with(url_for('stats/commit_activity'), params={'per_page': 100}, headers={})
'Test the ability to iterate over commits in a repo.'
def test_commits(self):
i = self.instance.commits() self.get_next(i) self.session.get.assert_called_once_with(url_for('commits'), params={'per_page': 100}, headers={})
'Test the ability to iterate over repo\'s commits in a date range.'
def test_commits_since_until_datetime(self):
i = self.instance.commits(since=datetime.datetime(2014, 8, 1), until='2014-09-01T00:00:00Z') self.get_next(i) self.session.get.assert_called_once_with(url_for('commits'), params={'per_page': 100, 'since': '2014-08-01T00:00:00Z', 'until': '2014-09-01T00:00:00Z'}, headers={})
'Test the ability to specify page size for commits listing.'
def test_commits_per_page(self):
i = self.instance.commits(per_page=10) self.get_next(i) self.session.get.assert_called_once_with(url_for('commits'), params={'per_page': 10}, headers={})
'Test the ability to filter commits by branch and path.'
def test_commits_sha_path(self):
i = self.instance.commits(sha='branch', path='tests/') self.get_next(i) self.session.get.assert_called_once_with(url_for('commits'), params={'per_page': 100, 'sha': 'branch', 'path': 'tests/'}, headers={})
'Test the ability to iterate over contributor statistics.'
def test_contributor_statistics(self):
i = self.instance.contributor_statistics() self.get_next(i) self.session.get.assert_called_once_with(url_for('stats/contributors'), params={'per_page': 100}, headers={})
'Test the ability to iterate over contributors to a repository.'
def test_contributors(self):
i = self.instance.contributors() self.get_next(i) self.session.get.assert_called_once_with(url_for('contributors'), params={'per_page': 100}, headers={})
'Test the ability to iterate over anonymous contributors.'
def test_contributors_with_anon(self):
i = self.instance.contributors(anon=True) self.get_next(i) self.session.get.assert_called_once_with(url_for('contributors'), params={'per_page': 100, 'anon': 'true'}, headers={})
'Test the ability to iterate over deployments.'
def test_deployments(self):
i = self.instance.deployments() self.get_next(i) self.session.get.assert_called_once_with(url_for('deployments'), params={'per_page': 100}, headers={})
'Test the ability to iterate over events from a repository.'
def test_events(self):
i = self.instance.events() self.get_next(i) self.session.get.assert_called_once_with(url_for('events'), params={'per_page': 100}, headers={})
'Test the ability to iterate over forks of a repository.'
def test_forks(self):
i = self.instance.forks() self.get_next(i) self.session.get.assert_called_once_with(url_for('forks'), params={'per_page': 100}, headers={})
'Test the ability to iterate over hooks of a repository.'
def test_hooks(self):
i = self.instance.hooks() self.get_next(i) self.session.get.assert_called_once_with(url_for('hooks'), params={'per_page': 100}, headers={})
'Verify the request for retreiving imported issues.'
def test_imported_issues(self):
i = self.instance.imported_issues(since='2015-03-15') self.get_next(i) self.session.get.assert_called_once_with(url_for('import/issues'), params={'per_page': 100, 'since': '2015-03-15'}, headers={'Accept': 'application/vnd.github.golden-comet-preview+json'})
'Test the ability to iterate over a repository\'s issue events.'
def test_issue_events(self):
i = self.instance.issue_events() self.get_next(i) self.session.get.assert_called_once_with(url_for('issues/events'), params={'per_page': 100}, headers={})
'Test the ability to iterate over a repository\'s issues.'
def test_issues(self):
i = self.instance.issues() self.get_next(i) self.session.get.assert_called_once_with(url_for('issues'), params={'per_page': 100}, headers={})
'Test the ability to iterate over a repository\'s keys.'
def test_keys(self):
i = self.instance.keys() self.get_next(i) self.session.get.assert_called_once_with(url_for('keys'), params={'per_page': 100}, headers={})
'Test the ability to iterate over a repository\'s labels.'
def test_labels(self):
i = self.instance.labels() self.get_next(i) self.session.get.assert_called_once_with(url_for('labels'), params={'per_page': 100}, headers={})
'Test the ability to iterate over the languages used in a repo.'
def test_languages(self):
i = self.instance.languages() self.get_next(i) self.session.get.assert_called_once_with(url_for('languages'), params={'per_page': 100}, headers={})
'Test the ability to iterate over the milestones in a repo.'
def test_milestones(self):
i = self.instance.milestones() self.get_next(i) self.session.get.assert_called_once_with(url_for('milestones'), params={'per_page': 100}, headers={})
'Test the ability to iterate over the network events for a repo.'
def test_network_events(self):
i = self.instance.network_events() self.get_next(i) self.session.get.assert_called_once_with(url_for('events').replace('repos', 'networks'), params={'per_page': 100}, headers={})
'Test the ability to iterate over the notifications for a repo.'
def test_notifications(self):
i = self.instance.notifications() self.get_next(i) self.session.get.assert_called_once_with(url_for('notifications'), params={'per_page': 100, 'participating': 'false', 'all': 'false'}, headers={})
'Test the request for the GitHub Pages builds for a repo.'
def test_pages_builds(self):
i = self.instance.pages_builds() self.get_next(i) self.session.get.assert_called_once_with(url_for('pages/builds'), params={'per_page': 100}, headers={})
'Test the request for the retrieving pull requests.'
def test_pull_requests(self):
i = self.instance.pull_requests() self.get_next(i) self.session.get.assert_called_once_with(url_for('pulls'), params={'per_page': 100, 'sort': 'created', 'direction': 'desc'}, headers={})
'Test the method ignores invalid pull request states.'
def test_pull_requests_ignore_invalid_state(self):
i = self.instance.pull_requests(state='invalid') self.get_next(i) self.session.get.assert_called_once_with(url_for('pulls'), params={'per_page': 100, 'sort': 'created', 'direction': 'desc'}, headers={})
'Test the request for retrieving references.'
def test_refs(self):
i = self.instance.refs() self.get_next(i) self.session.get.assert_called_once_with(url_for('git/refs'), params={'per_page': 100}, headers={})
'Test the request for retrieivng refs in a subspace.'
def test_refs_with_a_subspace(self):
i = self.instance.refs('a-subspace') self.get_next(i) self.session.get.assert_called_once_with(url_for('git/refs/a-subspace'), params={'per_page': 100}, headers={})
'Test the request for retrieving releases from a repository.'
def test_releases(self):
i = self.instance.releases() self.get_next(i) self.session.get.assert_called_once_with(url_for('releases'), params={'per_page': 100}, headers={'Accept': 'application/vnd.github.manifold-preview'})
'Test the request for retrieving stargazers of a repository.'
def test_stargazers(self):
i = self.instance.stargazers() self.get_next(i) self.session.get.assert_called_once_with(url_for('stargazers'), params={'per_page': 100}, headers={})
'Test the request for retrieiving statuses of a commit.'
def test_statuses(self):
i = self.instance.statuses('fake-sha') self.get_next(i) self.session.get.assert_called_once_with(url_for('statuses/fake-sha'), params={'per_page': 100}, headers={})
'Test the request is made only if given a SHA.'
def test_statuses_requires_a_sha(self):
i = self.instance.statuses('') self.get_next(i) assert (self.session.get.called is False)
'Test the request for retrieving subscribers to a repository.'
def test_subscribers(self):
i = self.instance.subscribers() self.get_next(i) self.session.get.assert_called_once_with(url_for('subscribers'), params={'per_page': 100}, headers={})
'Test the request for retrieving tags in a repository.'
def test_tags(self):
i = self.instance.tags() self.get_next(i) self.session.get.assert_called_once_with(url_for('tags'), params={'per_page': 100}, headers={})
'Test the request for retrieving teams on a repository.'
def test_teams(self):
i = self.instance.teams() self.get_next(i) self.session.get.assert_called_once_with(url_for('teams'), params={'per_page': 100}, headers={})
'Verify that adding a collaborator requires authentication.'
def test_add_collaborator(self):
with pytest.raises(GitHubError): self.instance.add_collaborator('foo')
'Verify that creating a tag requires authentication.'
def test_create_ref(self):
with pytest.raises(GitHubError): self.instance.create_ref('some ref', 'some sha')
'Verify that creating a file on a repository requires authentication.'
def test_create_file(self):
self.assert_requires_auth(self.instance.create_file)
'Verify that creating a fork requires authentication.'
def test_create_fork(self):
with pytest.raises(GitHubError): self.instance.create_fork()
'Verify that creating a hook requires authentication.'
def test_create_hook(self):
with pytest.raises(GitHubError): self.instance.create_hook('foo', 'config')
'Verify that creating an issue requires authentication.'
def test_create_issue(self):
with pytest.raises(GitHubError): self.instance.create_issue('some title', 'some body', 'foo')
'Verify that deploying a key requires authentication.'
def test_create_key(self):
with pytest.raises(GitHubError): self.instance.create_key('key name', 'ssh-rsa ...')
'Verify that creating a pull request requires authentication.'
def test_create_pull(self):
with pytest.raises(GitHubError): self.instance.create_pull(title='foo', base='master')
'Verify that creating a pull request from issue requires authentication.'
def test_create_pull_from_issue(self):
with pytest.raises(GitHubError): self.instance.create_pull_from_issue(issue=1, title='foo', base='master')
'Show that a user must be authenticated to create a status object on a commit.'
def test_create_status(self):
with pytest.raises(GitHubError): self.instance.create_status(sha='fake-sha')
'Show that a user must be authenticated to delete a key on a repository.'
def test_delete_key(self):
with pytest.raises(GitHubError): self.instance.delete_key(1)
'Show that deleting a subscription requires authentication.'
def test_delete_subscription(self):
with pytest.raises(GitHubError): self.instance.delete_subscription()
'Show that editing a repository requires authentication.'
def test_edit(self):
with pytest.raises(GitHubError): self.instance.edit(name='Hello')
'Show that checking if a user is collaborator on a repository requires authentication.'
def test_is_collaborator(self):
with pytest.raises(GitHubError): self.instance.is_collaborator('octocat')
'Show that a user must be authenticated to retrieve a hook.'
def test_hook(self):
with pytest.raises(GitHubError): self.instance.hook(1)
'Show that a user must be authenticated to list hooks.'
def test_hooks(self):
with pytest.raises(GitHubError): self.instance.hooks()
'Show that a user must be authenticated to import an issue.'
def test_import_issue(self):
with pytest.raises(GitHubError): self.instance.import_issue(title='foo', body='Foobar body', created_at='2014-03-16T17:15:42Z')
'Show that a user must be authenticated to retrieve imported issues.'
def test_imported_issues(self):
self.assert_requires_auth(self.instance.imported_issues)
'Show that a user must be authenticated to retrieve an imported issue.'
def test_imported_issue(self):
with pytest.raises(GitHubError): self.instance.import_issue(1)
'Show that a user must be authenticated to fetch a key.'
def test_key(self):
with pytest.raises(GitHubError): self.instance.key(10)
'Show that a user must be authenticated to list keys.'
def test_keys(self):
with pytest.raises(GitHubError): self.instance.keys()
'Show that a user must be authenticated to mark notifications as read.'
def test_mark_notifications(self):
with pytest.raises(GitHubError): self.instance.mark_notifications('2012-10-09T23:39:01Z')
'Show that a user must be authenticated to perform a merge on a repository.'
def test_merge(self):
with pytest.raises(GitHubError): self.instance.merge('master', 'octocat/feature')
'Show that a user must be authenticated to list notifications.'
def test_notifications(self):
with pytest.raises(GitHubError): self.instance.notifications()
'Show that a user must be authenticated to list their builds.'
def test_pages_builds(self):
with pytest.raises(GitHubError): self.instance.pages_builds()
'Show that a user must be authenticated to remove a collaborator.'
def test_remove_collaborator(self):
self.assert_requires_auth(self.instance.remove_collaborator)
'Show that a user must be authenticated to retrieve the subscription.'
def test_subscription(self):
self.assert_requires_auth(self.instance.subscription)
'Show that a user must be authenticated to list teams on a repo.'
def test_teams(self):
with pytest.raises(GitHubError): self.instance.teams()
'Verify the request for deleting content from a repository.'
def test_delete(self):
data = {'message': 'Deleting file from repository', 'branch': 'featureA', 'committer': {'name': 'Octocat', 'email': 'octocat@github.com'}, 'author': {'name': 'Octocat', 'email': 'octocat@github.com'}} self.instance.delete(**data) data.update({'sha': '3f4f0b9a43d13376679ee5710958ca88baa7c421'}) ...
'Veriy instance contains git url.'
def test_git_url(self):
assert (self.instance.links['git'] == self.instance.git_url)
'Verify instance contains html url.'
def test_html_url(self):
assert (self.instance.links['html'] == self.instance.html_url)
'Verify that instance string is formatted properly.'
def test_str(self):
assert (str(self.instance) == '<Content [{0}]>'.format(self.instance.path))
'Verify the request for updating a file\'s contents on a repository.'
def test_update(self):
data = {'message': 'Updating content files.', 'content': 'Updated content here.'} self.instance.update(**data) data.update({'content': b64encode(data['content']).decode('utf-8'), 'sha': self.instance.sha}) self.put_called_with(contents_url_for(), data=data)
'Verify the request for updating a file\'s contents on a repository.'
def test_update_required_content(self):
data = {'message': 'Updating content files.', 'content': 1} with pytest.raises(ValueError): self.instance.update(**data)
'Show that deleting content from a repository requires authentication.'
def test_delete(self):
self.assert_requires_auth(self.instance.delete)
'Show that updating a file\'s content on a repository requires authentication.'
def test_update(self):
self.assert_requires_auth(self.instance.update)
'Show that instance string is formatted correctly.'
def test_str(self):
assert (str(self.instance) == '<Hook [{0}]>'.format(self.instance.name))
'Verify the request for editing a hook on a repository.'
def test_delete(self):
self.instance.delete() self.session.delete.assert_called_once_with(hook_url_for())
'Verify the request for editing a hook on a repository.'
def test_edit(self):
config = {'url': 'https://fake-url.com', 'content_type': 'json'} self.instance.edit(config=config, events=['push'], add_events=['pull'], rm_events=['release']) data = {'config': config, 'events': ['push'], 'add_events': ['pull'], 'remove_events': ['release'], 'active': True} self.patch_called_with(hook_...
'Verify the request for editing a hook on a repository.'
def test_edit_failed(self):
assert (self.instance.edit() is False)
'Verify the request for ping a hook on a repository.'
def test_ping(self):
self.instance.ping() self.post_called_with(hook_url_for('pings'))
'Verify the request for testing a hook on a repository.'
def test_test(self):
self.instance.test() self.post_called_with(hook_url_for('tests'))
'Show that a user must be authenticated to delete a hook on a repository.'
def test_delete(self):
self.assert_requires_auth(self.instance.delete)
'Show that a user must be authenticated to edit a hook on a repository.'
def test_edit(self):
self.assert_requires_auth(self.instance.edit)
'Show that a user must be authenticated to ping a hook on a repository.'
def test_ping(self):
self.assert_requires_auth(self.instance.ping)
'Show that a user must be authenticated to test a hook on a repository.'
def test_test(self):
self.assert_requires_auth(self.instance.test)
'Verify the request for deleting a comment on a repository.'
def test_delete(self):
self.instance.delete() self.session.delete.assert_called_once_with(comment_url_for())
'Show that instance string is formatted correctly.'
def test_str(self):
assert str(self.instance).startswith('<Repository Comment')
'Verify the request for updating a comment on a repository.'
def test_update(self):
data = {'body': 'new body'} self.instance.update(body=data['body']) self.post_called_with(comment_url_for(), data=data)
'Show that a user must be authenticated to delete a comment on a repository.'
def test_delete(self):
self.assert_requires_auth(self.instance.delete)
'Show that a user must be authenticated to update a comment on a repository.'
def test_update(self):
self.assert_requires_auth(self.instance.update)
'Verify the request for retrieving the diff for a commit.'
def test_diff(self):
self.instance.diff() self.session.get.assert_called_once_with(commit_url_for(), headers={'Accept': 'application/vnd.github.diff'})
'Verify the request for retrieving the patch formatted diff for a commit.'
def test_patch(self):
self.instance.patch() self.session.get.assert_called_once_with(commit_url_for(), headers={'Accept': 'application/vnd.github.patch'})
'Show that instance string is formatted correctly.'
def test_str(self):
assert str(self.instance).startswith('<Repository Commit')
'Verify the request for retrieving a diff for this comparison.'
def test_diff(self):
self.instance.diff() self.session.get.assert_called_once_with(compare_url_for(), headers={'Accept': 'application/vnd.github.diff'})
'Verify the request for retrieving a diff for this comparison.'
def test_patch(self):
self.instance.patch() self.session.get.assert_called_once_with(compare_url_for(), headers={'Accept': 'application/vnd.github.patch'})
'Show that instance string is formatted correctly.'
def test_str(self):
assert str(self.instance).startswith('<Comparison')
'Show that attributes exist in class.'
def test_get_attr(self):
attributes = ['description', 'body', 'implementation', 'html_url', 'key', 'required', 'name', 'permitted', 'category', 'forbidden', 'featured'] for attr in attributes: assert getattr(self.instance, attr)
'Show that instance string is formatted properly.'
def test_repr(self):
assert repr(self.instance).startswith('<License')
'Test the request to retrieve a deployment\'s statuses.'
def test_statuses(self):
i = self.instance.statuses() self.get_next(i) self.session.get.assert_called_once_with(url_for('statuses'), params={'per_page': 100}, headers={})
'Verify instance message is correct.'
def test_message_is_empty(self):
response = requests.Response() response.status_code = 400 response.raw = io.BytesIO() error = GitHubError(response) assert (error.message == '[No message]')
'Verify instance message is correct.'
def test_message(self):
assert (self.instance.msg == self.instance.message)
'Verify instance string is formatted correctly.'
def test_str(self):
assert (str(self.instance) == '400 m')
'Verify boolean tests for response codes correctly.'
def test_boolean(self):
response = requests.Response() response.status_code = 200 boolean = self.instance._boolean(response=response, true_code=200, false_code=204) assert (boolean is True)
'Verify boolean tests for response codes correctly.'
def test_boolean_raises_exception(self):
response = requests.Response() response.status_code = 512 response.raw = io.BytesIO() with pytest.raises(exceptions.GitHubError): self.instance._boolean(response=response, true_code=200, false_code=204)
'Verify boolean tests for response codes correctly.'
def test_boolean_false_code(self):
response = requests.Response() response.status_code = 204 boolean = self.instance._boolean(response=response, true_code=200, false_code=204) assert (boolean is False)
'Verify boolean tests for response codes correctly.'
def test_boolean_empty_response(self):
boolean = self.instance._boolean(response=None, true_code=200, false_code=204) assert (boolean is False)