|
3 | 3 | import pytest
|
4 | 4 |
|
5 | 5 | from github3 import GitHubError
|
| 6 | +from github3.null import NullObject |
6 | 7 | from github3.repos.repo import Repository
|
7 | 8 |
|
8 | 9 | from .helper import (UnitHelper, UnitIteratorHelper, create_url_helper)
|
@@ -136,6 +137,21 @@ class TestRepository(UnitHelper):
|
136 | 137 | described_class = Repository
|
137 | 138 | example_data = repo_example_data
|
138 | 139 |
|
| 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 | + |
139 | 155 | def test_asset(self):
|
140 | 156 | """Test retrieving an asset uses the right headers.
|
141 | 157 |
|
@@ -687,6 +703,11 @@ def after_setup(self):
|
687 | 703 | """Set-up the session to not be authenticated."""
|
688 | 704 | self.session.has_auth.return_value = False
|
689 | 705 |
|
| 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 | + |
690 | 711 | def test_hooks(self):
|
691 | 712 | """Show that a user must be authenticated to list hooks."""
|
692 | 713 | with pytest.raises(GitHubError):
|
|
0 commit comments