aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/unit/test_gitlab.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/test_gitlab.py')
-rw-r--r--test/unit/test_gitlab.py46
1 files changed, 37 insertions, 9 deletions
diff --git a/test/unit/test_gitlab.py b/test/unit/test_gitlab.py
index 04a8f71..d708539 100644
--- a/test/unit/test_gitlab.py
+++ b/test/unit/test_gitlab.py
@@ -20,12 +20,40 @@ class GitLabTests(unittest.TestCase):
with self.assertRaises(GitlabGetError):
self.gitlab.projects.get('doesnot/exist')
- def test_existing_repo(self):
- r = self.gitlab.projects.get('egor-tensin/cgitize-test-repository')
- self.assertEqual(r.name, 'cgitize-test-repository')
- self.assertEqual(r.description, 'Test cgitize repository')
- self.assertEqual(r.namespace['name'], 'Egor Tensin')
- self.assertEqual(r.namespace['path'], 'egor-tensin')
- self.assertEqual(r.web_url, 'https://gitlab.com/egor-tensin/cgitize-test-repository')
- self.assertEqual(r.http_url_to_repo, 'https://gitlab.com/egor-tensin/cgitize-test-repository.git')
- self.assertEqual(r.ssh_url_to_repo, 'git@gitlab.com:egor-tensin/cgitize-test-repository.git')
+ def test_public_repo(self):
+ r = self.gitlab.projects.get('cgitize-test/public')
+ self.assertEqual(r.name, 'public')
+ self.assertEqual(r.description, 'Public test cgitize repository')
+ self.assertEqual(r.namespace['name'], 'Test cgitize user')
+ self.assertEqual(r.namespace['path'], 'cgitize-test')
+ self.assertEqual(r.web_url, 'https://gitlab.com/cgitize-test/public')
+ self.assertEqual(r.http_url_to_repo, 'https://gitlab.com/cgitize-test/public.git')
+ self.assertEqual(r.ssh_url_to_repo, 'git@gitlab.com:cgitize-test/public.git')
+
+ def test_private_repo(self):
+ r = self.gitlab.projects.get('cgitize-test/private')
+ self.assertEqual(r.name, 'private')
+ self.assertEqual(r.description, 'Private test cgitize repository')
+ self.assertEqual(r.namespace['name'], 'Test cgitize user')
+ self.assertEqual(r.namespace['path'], 'cgitize-test')
+ self.assertEqual(r.web_url, 'https://gitlab.com/cgitize-test/private')
+ self.assertEqual(r.http_url_to_repo, 'https://gitlab.com/cgitize-test/private.git')
+ self.assertEqual(r.ssh_url_to_repo, 'git@gitlab.com:cgitize-test/private.git')
+
+ def test_user(self):
+ u = self.gitlab.users.list(username='cgitize-test')
+ self.assertEqual(len(u), 1)
+ u = u[0]
+
+ rs = u.projects.list()
+ 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 GitLabTestPrivateRepo(unittest.TestCase):
+ def setUp(self):
+ self.gitlab = Gitlab('https://gitlab.com')
+
+ def test_private_repo(self):
+ with self.assertRaises(GitlabGetError):
+ self.gitlab.projects.get('cgitize-test/private')