8000 Add some more tests to convert · frossie/github3.py@724b485 · GitHub
[go: up one dir, main page]

Skip to content

Commit 724b485

Browse files
committed
Add some more tests to convert
1 parent 193fb76 commit 724b485

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

tests/integration/test_repos_repo.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ class TestRepository(helper.IntegrationHelper):
1111

1212
"""Integration tests for the Repository object."""
1313

14+
@pytest.skip('Need internet to record the cassette')
15+
def test_add_collaborator(self):
16+
"""Test the ability to add a collaborator to a repository."""
17+
self.basic_login()
18+
cassette_name = self.cassette_name('add_collaborator')
19+
with self.recorder.use_cassette(cassette_name):
20+
repository = self.gh.repository('github3py', 'fork_this')
21+
assert repository
22+
assert repository.add_collaborator('esacteksab')
23+
1424
def test_assignees(self):
1525
"""Test the ability to retrieve assignees of issues on a repo."""
1626
cassette_name = self.cassette_name('assignees')

tests/unit/test_repos_repo.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44

55
from github3 import GitHubError
6+
from github3.null import NullObject
67
from github3.repos.repo import Repository
78

89
from .helper import (UnitHelper, UnitIteratorHelper, create_url_helper)
@@ -136,6 +137,21 @@ class TestRepository(UnitHelper):
136137
described_class = Repository
137138
example_data = repo_example_data
138139

140+
def test_add_collaborator(self):
141+
"""Verify the request to add a collaborator to a repository."""
142+
self.instance.add_collaborator('sigmavirus24')
143+
144+
self.session.put.assert_called_once_with(
145+
url_for('collaborators/sigmavirus24')
146+
)
147+
148+
def test_add_null_collaborator(self):
149+
"""Verify no request is made when adding `None` as a collaborator."""
150+
self.instance.add_collaborator(None)
151+
self.instance.add_collaborator(NullObject())
152+
153+
assert self.session.put.called is False
154+
139155
def test_asset(self):
140156
"""Test retrieving an asset uses the right headers.
141157
@@ -687,6 +703,11 @@ def after_setup(self):
687703
"""Set-up the session to not be authenticated."""
688704
self.session.has_auth.return_value = False
689705

706+
def test_add_collaborator(self):
707+
"""Verify that adding a collaborator requires authentication."""
708+
with pytest.raises(GitHubError):
709+
self.instance.add_collaborator('foo')
710+
690711
def test_hooks(self):
691712
"""Show that a user must be authenticated to list hooks."""
692713
with pytest.raises(GitHubError):

0 commit comments

Comments
 (0)
0