aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/unit
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-07-31 17:39:46 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-07-31 17:39:46 +0300
commit8d2422274ae948f7412b6960597f5de91f3d8830 (patch)
tree88cc766fb5b0b11b685840dde7a896600583be6f /test/unit
parentrename "ssh" to "clone_via_ssh" in config (diff)
downloadcgitize-8d2422274ae948f7412b6960597f5de91f3d8830.tar.gz
cgitize-8d2422274ae948f7412b6960597f5de91f3d8830.zip
move all tests to test/
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/__init__.py0
-rw-r--r--test/unit/test_bitbucket.py36
-rw-r--r--test/unit/test_github.py27
3 files changed, 63 insertions, 0 deletions
diff --git a/test/unit/__init__.py b/test/unit/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/unit/__init__.py
diff --git a/test/unit/test_bitbucket.py b/test/unit/test_bitbucket.py
new file mode 100644
index 0000000..7a070ce
--- /dev/null
+++ b/test/unit/test_bitbucket.py
@@ -0,0 +1,36 @@
+# Copyright (c) 2021 Egor Tensin <Egor.Tensin@gmail.com>
+# 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 atlassian.bitbucket.cloud import Cloud
+from requests.exceptions import HTTPError
+
+
+class BitbucketTests(unittest.TestCase):
+ def setUp(self):
+ self.bitbucket = Cloud(cloud=True)
+
+ def test_nonexistent_repo(self):
+ with self.assertRaises(HTTPError):
+ self.bitbucket.repositories.get('doesnot/exist')
+
+ def test_existing_repo(self):
+ r = self.bitbucket.repositories.get('egor-tensin/cgitize-test-repository')
+ self.assertEqual(r['name'], 'cgitize-test-repository')
+ self.assertEqual(r['description'], 'Test cgitize repository')
+
+ self.assertEqual(r['owner']['display_name'], 'Egor Tensin')
+ self.assertEqual(r['owner']['nickname'], 'egor-tensin')
+
+ self.assertEqual(r['links']['html']['href'], 'https://bitbucket.org/egor-tensin/cgitize-test-repository')
+
+ clone_urls = [link for link in r['links']['clone'] if link['name'] == 'https']
+ self.assertEqual(len(clone_urls), 1)
+ self.assertEqual(clone_urls[0]['href'], 'https://bitbucket.org/egor-tensin/cgitize-test-repository.git')
+
+ ssh_urls = [link for link in r['links']['clone'] if link['name'] == 'ssh']
+ self.assertEqual(len(ssh_urls), 1)
+ self.assertEqual(ssh_urls[0]['href'], 'git@bitbucket.org:egor-tensin/cgitize-test-repository.git')
diff --git a/test/unit/test_github.py b/test/unit/test_github.py
new file mode 100644
index 0000000..be1daf6
--- /dev/null
+++ b/test/unit/test_github.py
@@ -0,0 +1,27 @@
+# Copyright (c) 2021 Egor Tensin <Egor.Tensin@gmail.com>
+# 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 github import Github, GithubException
+
+
+class GitHubTests(unittest.TestCase):
+ def setUp(self):
+ self.github = Github()
+
+ def test_nonexistent_repo(self):
+ 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')