-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
38 lines (31 loc) · 1.39 KB
/
test.py
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
29
30
31
32
33
34
35
36
37
38
import unittest
import os
import hub
class TestGitHub(unittest.TestCase):
github_token = os.getenv('GITHUB_TOKEN')
gh = hub.GitHub(github_token)
def test_init(self):
"""Test that the GitHub object can be instantiated."""
self.assertIsInstance(self.gh, hub.GitHub)
self.assertTrue(self.gh.organization is not None)
def test_get_all_repos(self):
"""Tests the functionality of using the GitHub
object to return a list of all repos in the org."""
repos = self.gh.get_all_repos()
self.assertGreater(len(repos), 1, msg="The GitHub org should have more than 1 repo present")
def test_get_all_repos_sorted(self):
"""Tests the functionality of using the GitHub
object to return a list of all repos in the org,
sorted by their last push datetime."""
repos = self.gh.get_all_repos(sort_by_last_push=True)
self.assertTrue(repos is not None)
self.assertGreater(len(repos), 1, msg="The GitHub org should have more than 1 repo present")
def test_get_repo(self):
"""Tests the functionality of getting a single repo."""
name = 'py-hub'
repo = self.gh.get_repo(name)
self.assertIsInstance(repo, hub.Repository)
self.assertEqual(repo.name, name)
self.assertTrue(repo.repo_obj is not None)
if __name__ == '__main__':
unittest.main()