Skip to content

Commit e32caa4

Browse files
Added TestUserKeyRequiresAuth per @sigmavirus24 suggestion.
1 parent 6d65671 commit e32caa4

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

tests/unit/test_users.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,32 @@
1919
example_data = get_users_example_data()
2020

2121

22+
class TestUserKeyRequiresAuth(UnitHelper):
23+
24+
"""Test that ensure certain methods on Key class requires auth."""
25+
26+
described_class = github3.users.Key
27+
example_data = get_user_key_example_data()
28+
29+
"""Test Key methods that require authentication."""
30+
def after_setup(self):
31+
self.session.has_auth.return_value = False
32+
33+
def test_update(self):
34+
"""Test that updating a key requires authentication."""
35+
with pytest.raises(github3.AuthenticationFailed):
36+
self.instance.update(title='New Title', key='Fake key')
37+
38+
def test_delete(self):
39+
"""Test that deleting a key requires authentication."""
40+
with pytest.raises(github3.AuthenticationFailed):
41+
self.instance.delete()
42+
43+
2244
class TestUserKey(UnitHelper):
45+
46+
"""Test methods on Key class."""
47+
2348
described_class = github3.users.Key
2449
example_data = get_user_key_example_data()
2550

@@ -39,7 +64,7 @@ def test_repr(self):
3964
def test_delete(self):
4065
"""Test the request for deleting key."""
4166
self.instance.delete()
42-
assert self.session.delete.called
67+
assert self.session.delete.called is True
4368

4469
def test_update(self):
4570
"""Test the request for updating a key."""

0 commit comments

Comments
 (0)