From cac16d1741a12856f7179cb779152bb9f4c41b18 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 16 Oct 2021 11:28:00 +0300 Subject: test/unit: add Gitlab unit tests --- test/unit/test_gitlab.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/unit/test_gitlab.py (limited to 'test') diff --git a/test/unit/test_gitlab.py b/test/unit/test_gitlab.py new file mode 100644 index 0000000..2c2f815 --- /dev/null +++ b/test/unit/test_gitlab.py @@ -0,0 +1,28 @@ +# Copyright (c) 2021 Egor Tensin +# This file is part of the "cgitize" project. +# For details, see https://github.com/egor-tensin/cgitize. +# Distributed under the MIT License. + +import unittest + +from gitlab import Gitlab +from gitlab.exceptions import GitlabGetError + + +class GitlabTests(unittest.TestCase): + def setUp(self): + self.gitlab = Gitlab('https://gitlab.com') + + def test_nonexistent_repo(self): + 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') -- cgit v1.2.3