testgithub.py 1.2 KB

1234567891011121314151617181920212223
  1. import unittest
  2. from mock import Mock, patch, MagicMock
  3. from django.conf import settings
  4. import hackathon.scripts.github as github
  5. class GithubTests(unittest.TestCase):
  6. def setUp(self):
  7. self.API_BASE_URL = 'https://api.github.com/users/DrkSephy'
  8. self.clientID = 'client_id=2404a1e21aebd902f6db'
  9. self.clientSecret = 'client_secret=3da44769d4b7c9465fa4c812669148a163607c23'
  10. self.jsonList = []
  11. @patch.object(github, 'getUserData')
  12. def testGetUserData(self, mock_getUserData):
  13. self.url = self.API_BASE_URL + '?' + self.clientID + '&' + self.clientSecret
  14. userData = Mock()
  15. match = {'name': 'test', 'blog': 'test', 'email': 'test', 'public_gists': 'test', 'public_repos': 'test','avatar_url': 'test', 'followers': 'test','following': 'test'}
  16. mock_getUserData.return_value = {'name': 'test', 'blog': 'test', 'email': 'test', 'public_gists': 'test', 'public_repos': 'test','avatar_url': 'test', 'followers': 'test','following': 'test'}
  17. self.assertEqual(github.getUserData(self.clientID, self.clientSecret), {'name': 'test', 'blog': 'test', 'email': 'test', 'public_gists': 'test', 'public_repos': 'test','avatar_url': 'test', 'followers': 'test','following': 'test'})
  18. # self.assertEqual('hello', 'hello')