def test_requires_auth(self): with expect.raises(github3.GitHubError): self.user.add_email_addresses(['*****@*****.**', '*****@*****.**']) self.user.delete_email_addresses(['*****@*****.**']) self.user.list_org_events(self.gh3py) self.user.update()
def test_requires_auth(self): if self.auth: return with expect.raises(github3.GitHubError): self.hook.edit('tweeter', self.hook.config) self.hook.delete() self.hook.test()
def test_watching(self): expect(self.g.list_watching(self.sigm)) != [] with expect.raises(github3.GitHubError): self.g.watch(self.sigm, self.todo) self.g.unwatch(self.sigm, self.todo) self.g.list_watching() self.g.is_watching(self.sigm, self.todo) if self.auth: expect(self._g.watch(self.sigm, self.todo)).isinstance(bool) expect(self._g.unwatch(self.sigm, self.todo)).isinstance(bool) expect(self._g.list_watching()) != [] expect(self._g.is_watching(self.sigm, self.todo)) != []
def test_oauth(self): # Test "oauth" auth self.g.login(token=self.fake_oauth) h = github3.login('', '', token=self.fake_oauth) for i in [self.g, h]: expect(i._session.headers['Authorization']) == 'token ' +\ self.fake_oauth with expect.raises(github3.GitHubError): self.g.user() if self.auth: expect(self._g.user()).is_not_None()
def test_requires_auth(self): with expect.raises(github3.GitHubError): self.org.add_member(self.kr, 'Collaborators') self.org.add_repo(self.test_repo, 'Collaborators') self.org.create_repo(self.test_repo + '2') self.org.conceal_member(self.sigm) self.org.create_team('New Team', permissions='pull') self.org.edit(name='github3[dot]py') self.org.list_teams() self.org.publicize_member(self.sigm) self.org.remove_member(self.sigm) self.org.remove_repo(self.test_repo, 'Collaborators') self.org.team(190083)
def test_following(self): expect(self.g.list_followers('kennethreitz')) != [] expect(self.g.list_following('kennethreitz')) != [] with expect.raises(github3.GitHubError): self.g.is_following(self.sigm) self.g.follow(self.sigm) self.g.unfollow(self.sigm) self.g.list_followers() self.g.list_following() if self.auth: expect(self._g.is_following(self.sigm)).isinstance(bool) expect(self._g.follow(self.sigm)).isinstance(bool) expect(self._g.unfollow(self.sigm)).isinstance(bool) expect(self._g.list_followers()) != [] expect(self._g.list_following()) != []
def test_requires_auth(self): repo = self.repo with expect.raises(github3.GitHubError): # It's going to fail anyway by default so the username is # unimportant repo.add_collaborator(self.sigm) repo.create_blob('Foo bar bogus', 'utf-8') repo.create_comment('Foo bar bogus', 'e8b7f5ad567faae369460f186ee0d82c90ccfbd1', 'todo.py', 5, 10) #repo.create_commit repo.create_download('file_to_download', '/tmp/foo') repo.create_fork(self.gh3py) repo.create_hook('Hook', {'foo': 'bar'}) repo.create_issue('New issue') repo.create_key('Key', 'foobarbogus') repo.create_label('Foo bar', 'abc123') repo.create_milestone('milestone') repo.create_pull('PR', '04d55444a3ec06ca8d2aa0a5e333cdaf27113254', '731691616b71258c7ad7c141379856b5ebbab310') repo.create_tag('fake_tag', 'fake tag message', '731691616b71258c7ad7c141379856b5ebbab310', 'commit', {'name': 'Ian Cordasco', 'email': '*****@*****.**'}) repo.create_tree({'path': 'tests/test_fake.py', 'mode': '100644', 'type': 'blob', 'sha': '731691616b71258c7ad7c141379856b5ebbab310'}) repo.delete() repo.edit('todo.py', '#', 'http://git.io/todo.py') repo.hook(74859) repo.key(1234) repo.list_keys() repo.list_teams() repo.pubsubhubub( 'subscribe', 'https://github.com/user/repo/events/push', 'https://httpbin.org/post' ) repo.remove_collaborator('foobarbogus') repo.update_label('Foo', 'abc123')
def test_gists(self): # My gcd example gist_id = 2648112 g = self.g.gist(gist_id) if not g: self.fail('Check gcd gist') expect(g).isinstance(github3.gists.Gist) with expect.raises(github3.GitHubError): self.g.gist(-1) for i in None, self.sigm: expect(self.g.list_gists(i)) != [] if self.auth: desc = 'Testing gist creation' files = {'test.txt': {'content': 'Test contents'}} gist = self._g.create_gist(desc, files, False) expect(gist).is_not_None() expect(gist.description) == desc expect(gist.is_public()).is_False() for g in gist.list_files(): expect(g.content) == files[g.name]['content'] expect(gist.delete()).is_True()
def test_issues(self): title = 'Test issue for github3.py' with expect.raises(github3.GitHubError): # Try to create one without authenticating self.g.create_issue(self.sigm, self.todo, title) # Try to get individual ones self.g.issue(self.sigm, self.todo, 2000) self.g.list_user_issues() i = self.g.issue(self.sigm, self.todo, 1) self.assertIsNotNone(i) expect(i).isinstance(github3.issues.Issue) expect(i.list_comments()) != [] # Test listing issues list_issues = self.g.list_repo_issues expect(list_issues(self.kr, 'requests')) != [] expect(list_issues(self.sigm, self.todo)).isinstance(list) for f in ('assigned', 'created', 'mentioned'): self.assertIsNotNone(list_issues(self.sigm, self.todo, f)) for s in ('open', 'closed'): self.assertIsNotNone(list_issues(self.sigm, self.todo, state=s)) self.assertIsNotNone(list_issues(self.sigm, self.todo, state='closed', labels='Bug,Enhancement')) for s in ('created', 'updated', 'comments'): self.assertIsNotNone(list_issues(self.sigm, self.todo, sort=s)) for d in ('asc', 'desc'): self.assertIsNotNone(list_issues(self.sigm, self.todo, state='closed', direction=d)) expect(list_issues(self.sigm, self.todo, since='2011-01-01T00:00:01Z')).is_not_None() if self.auth: i = self._g.create_issue(self.gh3py, self.test_repo, 'Testing github3.py', 'Ignore this.') expect(i).isinstance(github3.issue.Issue) expect(i.close()).is_True()
def test_list_emails(self): with expect.raises(github3.GitHubError): self.g.list_emails()
def test_requires_auth(self): if not self.auth: with expect.raises(github3.GitHubError): self.key.update('title', 'ssha-rsa AAAAB2...') self.key.delete()
def test_keys(self): with expect.raises(github3.GitHubError): self.g.create_key('Foo bar', 'bogus') self.g.delete_key(2000) self.g.get_key(2000) self.g.list_keys()
def test_repos(self): with expect.raises(github3.GitHubError): self.g.create_repo('test_github3.py') self.g.list_repos() expect(self.g.list_repos(self.sigm)) != [] expect(self.g.repository(self.sigm, self.todo)).is_not_None()
def test_users(self): with expect.raises(github3.GitHubError): self.g.update_user() self.g.user() expect(self.g.user(self.sigm)).is_not_None()
def test_orgs(self): expect(self.g.list_orgs(self.kr)) != [] expect(self.g.organization(self.gh3py)).is_not_None() with expect.raises(github3.GitHubError): self.g.list_orgs()
def test_requires_auth(self): with expect.raises(github3.GitHubError): self.dl.delete()
def test_auths(self): with expect.raises(github3.GitHubError): self.g.list_authorizations() self.g.authorization(-1) self.g.authorize('foo', 'bar', ['gist', 'user'])