Skip to content

Instantly share code, notes, and snippets.

@Ivaylo-Bachvarov
Last active August 29, 2015 14:05
Show Gist options
  • Save Ivaylo-Bachvarov/20b75205f7a7f7b99ead to your computer and use it in GitHub Desktop.
Save Ivaylo-Bachvarov/20b75205f7a7f7b99ead to your computer and use it in GitHub Desktop.
import unittest
from mock import patch
from github import Github, GithubException
def is_valid_repo(Github, user_name, repo_name):
github_client = Github("TOKEN_HERE")
try:
api_user = github_client.get_user(user_name)
api_repo = api_user.get_repo(repo_name)
return True
except GithubException:
return False
class Test(unittest.TestCase):
def test_is_valid_repo(self):
user_name = 'Ivaylo-Bachvarov'
repo_name = 'Telerik-Courses'
self.assertEqual(is_valid_repo(Github, user_name, repo_name), True)
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment