aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/unit/test_github.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-08-23 02:09:09 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-08-23 02:15:16 +0200
commit48e147c2894ce8dca9d2aa21a1369d5062580f03 (patch)
tree81bcc1be75fc1fad68e1d9e393749950692a7f6b /test/unit/test_github.py
parentrequirements.txt: bump dependencies (diff)
downloadcgitize-48e147c2894ce8dca9d2aa21a1369d5062580f03.tar.gz
cgitize-48e147c2894ce8dca9d2aa21a1369d5062580f03.zip
use separate users for testing
Diffstat (limited to 'test/unit/test_github.py')
-rw-r--r--test/unit/test_github.py50
1 files changed, 41 insertions, 9 deletions
diff --git a/test/unit/test_github.py b/test/unit/test_github.py
index 1095c98..7546ed6 100644
--- a/test/unit/test_github.py
+++ b/test/unit/test_github.py
@@ -17,12 +17,44 @@ class GitHubTests(unittest.TestCase):
with self.assertRaises(GithubException):
self.github.get_repo('doesnot/exist')
- def test_existing_repo(self):
- r = self.github.get_repo('egor-tensin/cgitize-test-repository')
- self.assertEqual(r.name, 'cgitize-test-repository')
- self.assertEqual(r.description, 'Test cgitize repository')
- self.assertEqual(r.owner.name, 'Egor Tensin')
- self.assertEqual(r.owner.login, 'egor-tensin')
- self.assertEqual(r.html_url, 'https://github.com/egor-tensin/cgitize-test-repository')
- self.assertEqual(r.clone_url, 'https://github.com/egor-tensin/cgitize-test-repository.git')
- self.assertEqual(r.ssh_url, 'git@github.com:egor-tensin/cgitize-test-repository.git')
+ def test_public_repo(self):
+ r = self.github.get_repo('cgitize-test/public')
+ self.assertEqual(r.name, 'public')
+ self.assertEqual(r.description, 'Public test cgitize repository')
+ self.assertEqual(r.owner.name, 'Test cgitize user')
+ self.assertEqual(r.owner.login, 'cgitize-test')
+ self.assertEqual(r.html_url, 'https://github.com/cgitize-test/public')
+ self.assertEqual(r.clone_url, 'https://github.com/cgitize-test/public.git')
+ self.assertEqual(r.ssh_url, 'git@github.com:cgitize-test/public.git')
+
+ def test_private_repo(self):
+ r = self.github.get_repo('cgitize-test/private')
+ self.assertEqual(r.name, 'private')
+ self.assertEqual(r.description, 'Private test cgitize repository')
+ self.assertEqual(r.owner.name, 'Test cgitize user')
+ self.assertEqual(r.owner.login, 'cgitize-test')
+ self.assertEqual(r.html_url, 'https://github.com/cgitize-test/private')
+ self.assertEqual(r.clone_url, 'https://github.com/cgitize-test/private.git')
+ self.assertEqual(r.ssh_url, 'git@github.com:cgitize-test/private.git')
+
+ def test_user(self):
+ # This is a bad way to get user's repositories: it'll return only
+ # public ones for on particular reason.
+ rs = self.github.get_user('cgitize-test').get_repos()
+ self.assertEqual(len([r for r in rs if r.name == 'public']), 1)
+ self.assertEqual(len([r for r in rs if r.name == 'private']), 0)
+
+ def test_user_authenticated(self):
+ # This is the way instead:
+ rs = self.github.get_user().get_repos()
+ self.assertEqual(len([r for r in rs if r.name == 'public']), 1)
+ self.assertEqual(len([r for r in rs if r.name == 'private']), 1)
+
+
+class GitHubTestPrivateRepo(unittest.TestCase):
+ def setUp(self):
+ self.github = Github()
+
+ def test_private_repo(self):
+ with self.assertRaises(GithubException):
+ self.github.get_repo('cgitize-test/private')