|
1 | 1 | import pytest
|
2 | 2 |
|
3 |
| -from github3 import AuthenticationFailed, GitHubEnterprise, GitHubError |
| 3 | +from github3 import GitHubEnterprise, GitHubError |
4 | 4 | from github3.github import GitHub, GitHubStatus
|
5 | 5 |
|
6 | 6 | from . import helper
|
@@ -1232,138 +1232,113 @@ class TestGitHubRequiresAuthentication(
|
1232 | 1232 |
|
1233 | 1233 | def test_add_email_addresses(self):
|
1234 | 1234 | """Verify a user must be authenticated to add email addresses."""
|
1235 |
| - with pytest.raises(AuthenticationFailed): |
1236 |
| - self.instance.add_email_addresses([]) |
| 1235 | + self.assert_requires_auth(self.instance.add_email_addresses, []) |
1237 | 1236 |
|
1238 | 1237 | def test_authorization(self):
|
1239 | 1238 | """A user must be authenticated to retrieve an authorization."""
|
1240 |
| - with pytest.raises(AuthenticationFailed): |
1241 |
| - self.instance.authorization(1) |
| 1239 | + self.assert_requires_auth(self.instance.authorization, 1) |
1242 | 1240 |
|
1243 | 1241 | def test_authorizations(self):
|
1244 | 1242 | """Show that one needs to authenticate to use #authorizations."""
|
1245 |
| - with pytest.raises(AuthenticationFailed): |
1246 |
| - self.instance.authorizations() |
| 1243 | + self.assert_requires_auth(self.instance.authorizations) |
1247 | 1244 |
|
1248 | 1245 | def test_create_issue(self):
|
1249 | 1246 | """Show that GitHub#create_issue requires auth."""
|
1250 |
| - with pytest.raises(AuthenticationFailed): |
1251 |
| - self.instance.create_issue('owner', 'repo', 'title') |
| 1247 | + self.assert_requires_auth(self.instance.create_issue, |
| 1248 | + 'owner', 'repo', 'title') |
1252 | 1249 |
|
1253 | 1250 | def test_create_key(self):
|
1254 | 1251 | """Show that GitHub#create_key requires auth."""
|
1255 |
| - with pytest.raises(AuthenticationFailed): |
1256 |
| - self.instance.create_key('title', 'key') |
| 1252 | + self.assert_requires_auth(self.instance.create_key, 'title', 'key') |
1257 | 1253 |
|
1258 | 1254 | def test_create_repository(self):
|
1259 | 1255 | """Show that GitHub#create_repository requires auth."""
|
1260 |
| - with pytest.raises(AuthenticationFailed): |
1261 |
| - self.instance.create_repository('repo') |
| 1256 | + self.assert_requires_auth(self.instance.create_repository, 'repo') |
1262 | 1257 |
|
1263 | 1258 | def test_delete_email_addresses(self):
|
1264 | 1259 | """Verify a user must be authenticated to delete email addresses."""
|
1265 |
| - with pytest.raises(AuthenticationFailed): |
1266 |
| - self.instance.delete_email_addresses([]) |
| 1260 | + self.assert_requires_auth(self.instance.delete_email_addresses, []) |
1267 | 1261 |
|
1268 | 1262 | def test_emails(self):
|
1269 | 1263 | """Show that one needs to authenticate to use #emails."""
|
1270 |
| - with pytest.raises(AuthenticationFailed): |
1271 |
| - self.instance.emails() |
| 1264 | + self.assert_requires_auth(self.instance.emails) |
1272 | 1265 |
|
1273 | 1266 | def test_feeds(self):
|
1274 | 1267 | """Show that one needs to authenticate to use #feeds."""
|
1275 |
| - with pytest.raises(AuthenticationFailed): |
1276 |
| - self.instance.feeds() |
| 1268 | + self.assert_requires_auth(self.instance.feeds) |
1277 | 1269 |
|
1278 | 1270 | def test_follow(self):
|
1279 | 1271 | """Show that one needs to authenticate to use #follow."""
|
1280 |
| - with pytest.raises(AuthenticationFailed): |
1281 |
| - self.instance.follow('foo') |
| 1272 | + self.assert_requires_auth(self.instance.follow, 'foo') |
1282 | 1273 |
|
1283 | 1274 | def test_gists(self):
|
1284 | 1275 | """Show that one needs to authenticate to use #gists."""
|
1285 |
| - with pytest.raises(AuthenticationFailed): |
1286 |
| - self.instance.gists() |
| 1276 | + self.assert_requires_auth(self.instance.gists) |
1287 | 1277 |
|
1288 | 1278 | def test_is_following(self):
|
1289 | 1279 | """Show that GitHub#is_following requires authentication."""
|
1290 |
| - with pytest.raises(AuthenticationFailed): |
1291 |
| - self.instance.is_following('foo') |
| 1280 | + self.assert_requires_auth(self.instance.is_following, 'foo') |
1292 | 1281 |
|
1293 | 1282 | def test_is_starred(self):
|
1294 | 1283 | """Show that GitHub#is_starred requires authentication."""
|
1295 |
| - with pytest.raises(AuthenticationFailed): |
1296 |
| - self.instance.is_starred('foo', 'bar') |
| 1284 | + self.assert_requires_auth(self.instance.is_starred, 'foo', 'bar') |
1297 | 1285 |
|
1298 | 1286 | def test_issues(self):
|
1299 | 1287 | """Show that one needs to authenticate to use #issues."""
|
1300 |
| - with pytest.raises(AuthenticationFailed): |
1301 |
| - self.instance.issues() |
| 1288 | + self.assert_requires_auth(self.instance.issues) |
1302 | 1289 |
|
1303 | 1290 | def test_key(self):
|
1304 | 1291 | """Show that retrieving user key requires authentication."""
|
1305 |
| - with pytest.raises(AuthenticationFailed): |
1306 |
| - self.instance.key(1) |
| 1292 | + self.assert_requires_auth(self.instance.key, 1) |
1307 | 1293 |
|
1308 | 1294 | def test_keys(self):
|
1309 | 1295 | """Show that one needs to authenticate to use #keys."""
|
1310 |
| - with pytest.raises(AuthenticationFailed): |
1311 |
| - self.instance.keys() |
| 1296 | + self.assert_requires_auth(self.instance.keys) |
1312 | 1297 |
|
1313 | 1298 | def test_me(self):
|
1314 | 1299 | """Show that GitHub#me requires authentication."""
|
1315 |
| - with pytest.raises(AuthenticationFailed): |
1316 |
| - self.instance.me() |
| 1300 | + self.assert_requires_auth(self.instance.me) |
1317 | 1301 |
|
1318 | 1302 | def test_notifications(self):
|
1319 | 1303 | """Show that one needs to authenticate to use #gists."""
|
1320 |
| - with pytest.raises(AuthenticationFailed): |
1321 |
| - self.instance.notifications() |
| 1304 | + self.assert_requires_auth(self.instance.notifications) |
1322 | 1305 |
|
1323 | 1306 | def test_organization_issues(self):
|
1324 | 1307 | """Show that one needs to authenticate to use #organization_issues."""
|
1325 |
| - with pytest.raises(AuthenticationFailed): |
1326 |
| - self.instance.organization_issues('org') |
| 1308 | + self.assert_requires_auth(self.instance.organization_issues, 'org') |
1327 | 1309 |
|
1328 | 1310 | def test_organizations(self):
|
1329 | 1311 | """Show that one needs to authenticate to use #organizations."""
|
1330 |
| - with pytest.raises(AuthenticationFailed): |
1331 |
| - self.instance.organizations() |
| 1312 | + self.assert_requires_auth(self.instance.organizations) |
1332 | 1313 |
|
1333 | 1314 | def test_pubsubhubbub(self):
|
1334 | 1315 | """Show that one needs to authenticate to use pull request."""
|
1335 |
| - with pytest.raises(AuthenticationFailed): |
1336 |
| - self.instance.pubsubhubbub(mode='', topic='', callback='') |
| 1316 | + self.assert_requires_auth(self.instance.pubsubhubbub, |
| 1317 | + mode='', topic='', callback='') |
1337 | 1318 |
|
1338 | 1319 | def test_repositories(self):
|
1339 | 1320 | """Show that one needs to authenticate to use #repositories."""
|
1340 |
| - with pytest.raises(AuthenticationFailed): |
1341 |
| - self.instance.repositories() |
| 1321 | + self.assert_requires_auth(self.instance.repositories) |
1342 | 1322 |
|
1343 | 1323 | def test_star(self):
|
1344 | 1324 | """Show that starring a repository requires authentication."""
|
1345 |
| - with pytest.raises(AuthenticationFailed): |
1346 |
| - self.instance.star(username='', repo='') |
| 1325 | + self.assert_requires_auth(self.instance.star, username='', repo='') |
1347 | 1326 |
|
1348 | 1327 | def test_starred(self):
|
1349 | 1328 | """Show that one needs to authenticate to use #starred."""
|
1350 |
| - with pytest.raises(AuthenticationFailed): |
1351 |
| - self.instance.starred() |
| 1329 | + self.assert_requires_auth(self.instance.starred) |
1352 | 1330 |
|
1353 | 1331 | def test_unfollow(self):
|
1354 | 1332 | """Show that unfollowing a user requires authentication."""
|
1355 |
| - with pytest.raises(AuthenticationFailed): |
1356 |
| - self.instance.unfollow('foo') |
| 1333 | + self.assert_requires_auth(self.instance.unfollow, 'foo') |
1357 | 1334 |
|
1358 | 1335 | def test_unstar(self):
|
1359 | 1336 | """Show that unstarring requires authentication."""
|
1360 |
| - with pytest.raises(AuthenticationFailed): |
1361 |
| - self.instance.unstar(username='', repo='') |
| 1337 | + self.assert_requires_auth(self.instance.unstar, username='', repo='') |
1362 | 1338 |
|
1363 | 1339 | def test_user_issues(self):
|
1364 | 1340 | """Show that GitHub#user_issues requires authentication."""
|
1365 |
| - with pytest.raises(AuthenticationFailed): |
1366 |
| - self.instance.user_issues() |
| 1341 | + self.assert_requires_auth(self.instance.user_issues) |
1367 | 1342 |
|
1368 | 1343 |
|
1369 | 1344 | class TestGitHubAuthorizations(helper.UnitHelper):
|
|
0 commit comments