aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.github/workflows/ci.yml8
-rw-r--r--.gitignore1
-rw-r--r--requirements.txt2
-rw-r--r--test/__init__.py0
-rw-r--r--test/test_bitbucket.py34
-rw-r--r--test/test_github.py26
6 files changed, 69 insertions, 2 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2867eda..da2f831 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -23,8 +23,12 @@ jobs:
run: |
git config --global user.name 'John Doe'
git config --global user.email 'John.Doe@example.com'
- - name: Test
+ - name: Install dependencies
+ run: pip install -r requirements.txt
+ - name: Integration tests
run: ./.ci/local/test.sh
+ - name: Unit tests
+ run: python -m unittest --buffer
test_docker:
runs-on: ubuntu-latest
@@ -32,7 +36,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- - name: Test
+ - name: Integration tests
run: ./.ci/docker/test.sh
publish_docker:
diff --git a/.gitignore b/.gitignore
index 8b77993..5935c49 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
__pycache__/
*.pyc
+/.venv/
/build/
/dist/
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..f8d7d23
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,2 @@
+PyGithub ~= 1.0
+atlassian-python-api ~= 3.0
diff --git a/test/__init__.py b/test/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/__init__.py
diff --git a/test/test_bitbucket.py b/test/test_bitbucket.py
new file mode 100644
index 0000000..776c48c
--- /dev/null
+++ b/test/test_bitbucket.py
@@ -0,0 +1,34 @@
+# 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')
+
+ https_links = [link for link in r['links']['clone'] if link['name'] == 'https']
+ self.assertEqual(len(https_links), 1)
+ self.assertEqual(https_links[0]['href'], 'https://bitbucket.org/egor-tensin/cgitize-test-repository.git')
+
+ ssh_links = [link for link in r['links']['clone'] if link['name'] == 'ssh']
+ self.assertEqual(len(ssh_links), 1)
+ self.assertEqual(ssh_links[0]['href'], 'git@bitbucket.org:egor-tensin/cgitize-test-repository.git')
+
+ self.assertEqual(r['owner']['display_name'], 'Egor Tensin')
+ self.assertEqual(r['owner']['nickname'], 'egor-tensin')
diff --git a/test/test_github.py b/test/test_github.py
new file mode 100644
index 0000000..ab96ecc
--- /dev/null
+++ b/test/test_github.py
@@ -0,0 +1,26 @@
+# 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.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')
+ self.assertEqual(r.owner.name, 'Egor Tensin')
+ self.assertEqual(r.owner.login, 'egor-tensin')