diff options
Diffstat (limited to 'test/unit/test_bitbucket.py')
-rw-r--r-- | test/unit/test_bitbucket.py | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/test/unit/test_bitbucket.py b/test/unit/test_bitbucket.py index 2e49168..7611bd4 100644 --- a/test/unit/test_bitbucket.py +++ b/test/unit/test_bitbucket.py @@ -14,27 +14,51 @@ class BitbucketTests(unittest.TestCase): def setUp(self): self.bitbucket = Cloud( username=os.environ.get('CGITIZE_BITBUCKET_USERNAME'), - password=os.environ.get('CGITIZE_BITBUCKET_PASSWORD'), + password=os.environ.get('CGITIZE_BITBUCKET_TOKEN'), 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') + 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') - self.assertEqual(r.data['owner']['display_name'], 'Egor Tensin') - self.assertEqual(r.data['owner']['nickname'], 'egor-tensin') + self.assertEqual(r.data['workspace']['name'], 'Test cgitize workspace') + self.assertEqual(r.data['workspace']['slug'], 'cgitize-test-workspace') - self.assertEqual(r.get_link('html'), 'https://bitbucket.org/egor-tensin/cgitize-test-repository') + self.assertEqual(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'] self.assertEqual(len(clone_urls), 1) - self.assertEqual(clone_urls[0]['href'], 'https://bitbucket.org/egor-tensin/cgitize-test-repository.git') + self.assertEqual(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'] self.assertEqual(len(ssh_urls), 1) - self.assertEqual(ssh_urls[0]['href'], 'git@bitbucket.org:egor-tensin/cgitize-test-repository.git') + self.assertEqual(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') + + self.assertEqual(r.data['workspace']['name'], 'Test cgitize workspace') + self.assertEqual(r.data['workspace']['slug'], 'cgitize-test-workspace') + + self.assertEqual(r.get_link('html'), 'https://bitbucket.org/cgitize-test-workspace/private') + + def test_user(self): + w = self.bitbucket.workspaces.get('cgitize-test-workspace') + self.assertEqual(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) + + +class BitbucketTestPrivateRepo(unittest.TestCase): + def setUp(self): + self.bitbucket = Cloud(cloud=True) + + def test_private_repo(self): + with self.assertRaises(HTTPError): + self.bitbucket.repositories.get('cgitize-test-workspace', 'private') |