RawData.py
1 ############################ Copyrights and license ############################ 2 # # 3 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # 4 # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> # 5 # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> # 6 # Copyright 2018 sfdye <tsfdye@gmail.com> # 7 # # 8 # This file is part of PyGithub. # 9 # http://pygithub.readthedocs.io/ # 10 # # 11 # PyGithub is free software: you can redistribute it and/or modify it under # 12 # the terms of the GNU Lesser General Public License as published by the Free # 13 # Software Foundation, either version 3 of the License, or (at your option) # 14 # any later version. # 15 # # 16 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 18 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 19 # details. # 20 # # 21 # You should have received a copy of the GNU Lesser General Public License # 22 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 23 # # 24 ################################################################################ 25 26 import github.NamedUser 27 28 from . import Framework 29 30 31 class RawData(Framework.TestCase): 32 jacquev6RawData = { 33 "disk_usage": 13812, 34 "private_gists": 5, 35 "public_repos": 21, 36 "subscriptions_url": "https://api.github.com/users/jacquev6/subscriptions", 37 "gravatar_id": "b68de5ae38616c296fa345d2b9df2225", 38 "hireable": False, 39 "id": 327146, 40 "followers_url": "https://api.github.com/users/jacquev6/followers", 41 "following_url": "https://api.github.com/users/jacquev6/following", 42 "collaborators": 1, 43 "total_private_repos": 4, 44 "blog": "http://vincent-jacques.net", 45 "followers": 22, 46 "location": "Paris, France", 47 "type": "User", 48 "email": "vincent@vincent-jacques.net", 49 "bio": "", 50 "gists_url": "https://api.github.com/users/jacquev6/gists{/gist_id}", 51 "owned_private_repos": 4, 52 "company": "Criteo", 53 "events_url": "https://api.github.com/users/jacquev6/events{/privacy}", 54 "html_url": "https://github.com/jacquev6", 55 "updated_at": "2013-03-12T22:13:32Z", 56 "plan": { 57 "collaborators": 1, 58 "name": "micro", 59 "private_repos": 5, 60 "space": 614400, 61 }, 62 "received_events_url": "https://api.github.com/users/jacquev6/received_events", 63 "starred_url": "https://api.github.com/users/jacquev6/starred{/owner}{/repo}", 64 "public_gists": 2, 65 "name": "Vincent Jacques", 66 "organizations_url": "https://api.github.com/users/jacquev6/orgs", 67 "url": "https://api.github.com/users/jacquev6", 68 "created_at": "2010-07-09T06:10:06Z", 69 "avatar_url": "https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png", 70 "repos_url": "https://api.github.com/users/jacquev6/repos", 71 "following": 38, 72 "login": "jacquev6", 73 } 74 75 planRawData = { 76 "collaborators": 1, 77 "name": "micro", 78 "private_repos": 5, 79 "space": 614400, 80 } 81 82 def testCompletedObject(self): 83 user = self.g.get_user("jacquev6") 84 self.assertTrue(user._CompletableGithubObject__completed) 85 self.assertEqual(user.raw_data, RawData.jacquev6RawData) 86 87 def testNotYetCompletedObject(self): 88 user = self.g.get_user().get_repo("PyGithub").owner 89 self.assertFalse(user._CompletableGithubObject__completed) 90 self.assertEqual(user.raw_data, RawData.jacquev6RawData) 91 self.assertTrue(user._CompletableGithubObject__completed) 92 93 def testNonCompletableObject(self): 94 plan = self.g.get_user().plan 95 self.assertEqual(plan.raw_data, RawData.planRawData) 96 97 def testCreateObjectFromRawData(self): 98 user = self.g.create_from_raw_data(github.NamedUser.NamedUser, RawData.jacquev6RawData) 99 self.assertEqual(user._CompletableGithubObject__completed, True) 100 self.assertEqual(user.name, "Vincent Jacques")