aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/unit/test_github.py
blob: 1095c984f10a03cbc3f00bf0daa35daa06cfb334 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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 os
import unittest

from github import Github, GithubException


class GitHubTests(unittest.TestCase):
    def setUp(self):
        self.github = Github(os.environ.get('CGITIZE_GITHUB_TOKEN'))

    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')