diff options
| author | Egor Tensin <egor@tensin.name> | 2026-06-23 18:06:51 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-06-23 18:06:51 +0200 |
| commit | ebbab9207fc3ec5dcf2df9011d945a8de2617983 (patch) | |
| tree | 9c01a22bc786ba6d30cb3e02d76f8b22b86107b6 /test | |
| parent | shorter level names in logs (diff) | |
| download | cgitize-ebbab9207fc3ec5dcf2df9011d945a8de2617983.tar.gz cgitize-ebbab9207fc3ec5dcf2df9011d945a8de2617983.zip | |
use default settings for Black
Diffstat (limited to 'test')
| -rw-r--r-- | test/unit/test_bitbucket.py | 62 | ||||
| -rw-r--r-- | test/unit/test_github.py | 52 | ||||
| -rw-r--r-- | test/unit/test_gitlab.py | 50 |
3 files changed, 82 insertions, 82 deletions
diff --git a/test/unit/test_bitbucket.py b/test/unit/test_bitbucket.py index e81cdef..29b69ff 100644 --- a/test/unit/test_bitbucket.py +++ b/test/unit/test_bitbucket.py @@ -13,80 +13,80 @@ from requests.exceptions import HTTPError class BitbucketTests(unittest.TestCase): def setUp(self): self.bitbucket = Cloud( - username=os.environ.get('CGITIZE_BITBUCKET_EMAIL'), - password=os.environ.get('CGITIZE_BITBUCKET_TOKEN'), + username=os.environ.get("CGITIZE_BITBUCKET_EMAIL"), + password=os.environ.get("CGITIZE_BITBUCKET_TOKEN"), cloud=True, ) def test_nonexistent_repo(self): with self.assertRaises(HTTPError): - self.bitbucket.repositories.get('doesnot', 'exist') + self.bitbucket.repositories.get("doesnot", "exist") def test_public_repo(self): - r = self.bitbucket.repositories.get('cgitize-test-workspace', 'public') - self.assertEqual(r.name, 'public') - self.assertEqual(r.description, 'Public test cgitize repository') + r = self.bitbucket.repositories.get("cgitize-test-workspace", "public") + self.assertEqual(r.name, "public") + self.assertEqual(r.description, "Public test cgitize repository") - self.assertEqual(r.data['workspace']['name'], 'Test cgitize workspace') - self.assertEqual(r.data['workspace']['slug'], 'cgitize-test-workspace') + self.assertEqual(r.data["workspace"]["name"], "Test cgitize workspace") + self.assertEqual(r.data["workspace"]["slug"], "cgitize-test-workspace") - self.assertFalse(r.data['is_private']) + self.assertFalse(r.data["is_private"]) self.assertEqual( - r.get_link('html'), 'https://bitbucket.org/cgitize-test-workspace/public' + r.get_link("html"), "https://bitbucket.org/cgitize-test-workspace/public" ) clone_urls = [ - link for link in r.data['links']['clone'] if link['name'] == 'https' + link for link in r.data["links"]["clone"] if link["name"] == "https" ] self.assertEqual(len(clone_urls), 1) self.assertEqual( - clone_urls[0]['href'], - 'https://cgitize-test@bitbucket.org/cgitize-test-workspace/public.git', + clone_urls[0]["href"], + "https://cgitize-test@bitbucket.org/cgitize-test-workspace/public.git", ) - ssh_urls = [link for link in r.data['links']['clone'] if link['name'] == 'ssh'] + ssh_urls = [link for link in r.data["links"]["clone"] if link["name"] == "ssh"] self.assertEqual(len(ssh_urls), 1) self.assertEqual( - ssh_urls[0]['href'], 'git@bitbucket.org:cgitize-test-workspace/public.git' + ssh_urls[0]["href"], "git@bitbucket.org:cgitize-test-workspace/public.git" ) def test_private_repo(self): - r = self.bitbucket.repositories.get('cgitize-test-workspace', 'private') - self.assertEqual(r.name, 'private') - self.assertEqual(r.description, 'Private test cgitize repository') + r = self.bitbucket.repositories.get("cgitize-test-workspace", "private") + self.assertEqual(r.name, "private") + self.assertEqual(r.description, "Private test cgitize repository") - self.assertEqual(r.data['workspace']['name'], 'Test cgitize workspace') - self.assertEqual(r.data['workspace']['slug'], 'cgitize-test-workspace') + self.assertEqual(r.data["workspace"]["name"], "Test cgitize workspace") + self.assertEqual(r.data["workspace"]["slug"], "cgitize-test-workspace") - self.assertTrue(r.data['is_private']) + self.assertTrue(r.data["is_private"]) self.assertEqual( - r.get_link('html'), 'https://bitbucket.org/cgitize-test-workspace/private' + r.get_link("html"), "https://bitbucket.org/cgitize-test-workspace/private" ) clone_urls = [ - link for link in r.data['links']['clone'] if link['name'] == 'https' + link for link in r.data["links"]["clone"] if link["name"] == "https" ] self.assertEqual(len(clone_urls), 1) self.assertEqual( - clone_urls[0]['href'], - 'https://cgitize-test@bitbucket.org/cgitize-test-workspace/private.git', + clone_urls[0]["href"], + "https://cgitize-test@bitbucket.org/cgitize-test-workspace/private.git", ) - ssh_urls = [link for link in r.data['links']['clone'] if link['name'] == 'ssh'] + ssh_urls = [link for link in r.data["links"]["clone"] if link["name"] == "ssh"] self.assertEqual(len(ssh_urls), 1) self.assertEqual( - ssh_urls[0]['href'], 'git@bitbucket.org:cgitize-test-workspace/private.git' + ssh_urls[0]["href"], "git@bitbucket.org:cgitize-test-workspace/private.git" ) def test_user(self): - w = self.bitbucket.workspaces.get('cgitize-test-workspace') + w = self.bitbucket.workspaces.get("cgitize-test-workspace") self.assertEqual( - len([r for r in w.repositories.each() if r.name == 'public']), 1 + len([r for r in w.repositories.each() if r.name == "public"]), 1 ) self.assertEqual( - len([r for r in w.repositories.each() if r.name == 'private']), 1 + len([r for r in w.repositories.each() if r.name == "private"]), 1 ) @@ -96,4 +96,4 @@ class BitbucketTestPrivateRepo(unittest.TestCase): def test_private_repo(self): with self.assertRaises(HTTPError): - self.bitbucket.repositories.get('cgitize-test-workspace', 'private') + self.bitbucket.repositories.get("cgitize-test-workspace", "private") diff --git a/test/unit/test_github.py b/test/unit/test_github.py index 054234b..45e7360 100644 --- a/test/unit/test_github.py +++ b/test/unit/test_github.py @@ -11,46 +11,46 @@ from github import Auth, Github, GithubException class GitHubTests(unittest.TestCase): def setUp(self): - self.github = Github(auth=Auth.Token(os.environ.get('CGITIZE_GITHUB_TOKEN'))) + self.github = Github(auth=Auth.Token(os.environ.get("CGITIZE_GITHUB_TOKEN"))) def test_nonexistent_repo(self): with self.assertRaises(GithubException): - self.github.get_repo('doesnot/exist') + self.github.get_repo("doesnot/exist") 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.visibility, 'public') - 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') + 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.visibility, "public") + 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.visibility, 'private') - 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') + 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.visibility, "private") + 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) + 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) + 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): @@ -59,4 +59,4 @@ class GitHubTestPrivateRepo(unittest.TestCase): def test_private_repo(self): with self.assertRaises(GithubException): - self.github.get_repo('cgitize-test/private') + self.github.get_repo("cgitize-test/private") diff --git a/test/unit/test_gitlab.py b/test/unit/test_gitlab.py index f0b3b4a..cb34f47 100644 --- a/test/unit/test_gitlab.py +++ b/test/unit/test_gitlab.py @@ -13,53 +13,53 @@ from gitlab.exceptions import GitlabGetError class GitLabTests(unittest.TestCase): def setUp(self): self.gitlab = Gitlab( - 'https://gitlab.com', private_token=os.environ.get('CGITIZE_GITLAB_TOKEN') + "https://gitlab.com", private_token=os.environ.get("CGITIZE_GITLAB_TOKEN") ) def test_nonexistent_repo(self): with self.assertRaises(GitlabGetError): - self.gitlab.projects.get('doesnot/exist') + self.gitlab.projects.get("doesnot/exist") 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.visibility, 'public') - self.assertEqual(r.web_url, 'https://gitlab.com/cgitize-test/public') + 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.visibility, "public") + 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' + 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') + 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.visibility, 'private') - self.assertEqual(r.web_url, 'https://gitlab.com/cgitize-test/private') + 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.visibility, "private") + 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' + 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') + 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') + 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) + 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') + self.gitlab = Gitlab("https://gitlab.com") def test_private_repo(self): with self.assertRaises(GitlabGetError): - self.gitlab.projects.get('cgitize-test/private') + self.gitlab.projects.get("cgitize-test/private") |
