예제 #1
0
    def test_with_auth(self):
        if not self.auth:
            return
        # Try and do something only sigmavirus24 or other org members
        # should be able to do. As of now (26 Aug 2012) there are no other
        # org members.
        # Might as well avoid a call to the API, right?
        org = Organization(self.org.to_json(), self._g)
        try:
            expect(org.add_member('jcordasc', 'Collaborators')).is_True()
            expect(org.remove_member('jcordasc', 'Collaborators')).is_True()
        except github3.GitHubError:
            pass

        try:
            expect(org.add_repo(self.test_repo, 'Contributors')).is_True()
            expect(org.remove_repo(self.test_repo, 'Contributors')).is_True()
        except github3.GitHubError:
            pass

        try:
            repo = org.create_repo('test_repo_creation', 'testing')
            expect(repo).isinstance(Repository)
            repo.delete()
        except github3.GitHubError:
            pass

        try:
            expect(org.conceal_member(self.sigm)).is_True()
            expect(org.publicize_member(self.sigm)).is_True()
        except github3.GitHubError:
            pass

        try:
            team = org.create_team('New Team', permissions='admin')
            expect(team).isinstance(Team)
            team.delete()
        except github3.GitHubError:
            pass

        try:
            expect(org.edit(name='github3[dot]py')).is_True()
            expect(org.edit(name='github3.py')).is_True()
        except github3.GitHubError:
            pass

        try:
            teams = org.list_teams()
            self.expect_list_of_class(teams, Team)
        except github3.GitHubError:
            pass

        try:
            expect(org.team(190083)).isinstance(Team)
        except github3.GitHubError:
            pass
예제 #2
0
    def test_with_auth(self):
        if not self.auth:
            return
        # Try and do something only sigmavirus24 or other org members
        # should be able to do. As of now (26 Aug 2012) there are no other
        # org members.
        # Might as well avoid a call to the API, right?
        org = Organization(self.org.to_json(), self._g)
        try:
            expect(org.add_member('gh3test', 'Collaborators')).is_True()
            expect(org.remove_member('gh3test')).is_True()
        except github3.GitHubError:
            pass

        try:
            repo = self.gh3py + '/' + self.test_repo
            expect(org.add_repo(repo, 'Contributors')).is_True()
            expect(org.remove_repo(repo, 'Contributors')).is_True()
        except github3.GitHubError:
            pass

        try:
            repo = org.create_repo('test_repo_creation', 'testing',
                    team_id=190083)
            expect(repo).isinstance(Repository)
            repo.delete()
        except github3.GitHubError:
            pass

        try:
            expect(org.conceal_member(self.sigm)).is_True()
            expect(org.publicize_member(self.sigm)).is_True()
        except github3.GitHubError:
            pass

        try:
            team = org.create_team('New Team', permissions='admin')
            expect(team).isinstance(Team)
            team.delete()
        except github3.GitHubError:
            pass

        try:
            expect(org.edit(name='github3[dot]py')).is_True()
            expect(org.edit(name='github3.py')).is_True()
        except github3.GitHubError:
            pass

        try:
            teams = org.list_teams()
            expect(teams).list_of(Team)
        except github3.GitHubError:
            pass

        try:
            expect(next(org.iter_teams())).isinstance(Team)
        except github3.GitHubError:
            pass

        try:
            expect(org.team(190083)).isinstance(Team)
        except github3.GitHubError:
            pass

        try:
            expect(org.add_member(self.sigm, 'Foo')).is_False()
        except github3.GitHubError:
            pass

        try:
            expect(org.add_repo(self.test_repo, 'Foo')).is_False()
        except github3.GitHubError:
            pass

        try:
            co = org.company
            em = org.email
            loc = org.location
            name = org.name
            expect(org.edit()).is_False()
            expect(org.edit(None, 'github3.io', em, loc, name)).is_True()
            expect(org.edit(None, co, em, loc, name)).is_True()
        except github3.GitHubError:
            pass

        try:
            expect(org.remove_repo(self.test_repo, 'Foo')).isinstance(bool)
        except github3.GitHubError:
            pass