Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/github/tests/AuthenticatedUser.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author | bcclaywell |
---|---|
date | Mon, 12 Oct 2015 17:43:33 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d67268158946 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 # ########################## Copyrights and license ############################ | |
4 # # | |
5 # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> # | |
6 # Copyright 2012 Zearin <zearin@gonk.net> # | |
7 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # | |
8 # # | |
9 # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # | |
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 Framework | |
27 | |
28 import github | |
29 import datetime | |
30 | |
31 | |
32 class AuthenticatedUser(Framework.TestCase): | |
33 def setUp(self): | |
34 Framework.TestCase.setUp(self) | |
35 self.user = self.g.get_user() | |
36 | |
37 def testAttributes(self): | |
38 self.assertEqual(self.user.avatar_url, "https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png") | |
39 self.assertEqual(self.user.bio, "") | |
40 self.assertEqual(self.user.blog, "http://vincent-jacques.net") | |
41 self.assertEqual(self.user.collaborators, 0) | |
42 self.assertEqual(self.user.company, "Criteo") | |
43 self.assertEqual(self.user.created_at, datetime.datetime(2010, 7, 9, 6, 10, 6)) | |
44 self.assertEqual(self.user.disk_usage, 16692) | |
45 self.assertEqual(self.user.email, "vincent@vincent-jacques.net") | |
46 self.assertEqual(self.user.followers, 13) | |
47 self.assertEqual(self.user.following, 24) | |
48 self.assertEqual(self.user.gravatar_id, "b68de5ae38616c296fa345d2b9df2225") | |
49 self.assertFalse(self.user.hireable) | |
50 self.assertEqual(self.user.html_url, "https://github.com/jacquev6") | |
51 self.assertEqual(self.user.id, 327146) | |
52 self.assertEqual(self.user.location, "Paris, France") | |
53 self.assertEqual(self.user.login, "jacquev6") | |
54 self.assertEqual(self.user.name, "Vincent Jacques") | |
55 self.assertEqual(self.user.owned_private_repos, 5) | |
56 self.assertEqual(self.user.plan.name, "micro") | |
57 self.assertEqual(self.user.plan.collaborators, 1) | |
58 self.assertEqual(self.user.plan.space, 614400) | |
59 self.assertEqual(self.user.plan.private_repos, 5) | |
60 self.assertEqual(self.user.private_gists, 5) | |
61 self.assertEqual(self.user.public_gists, 1) | |
62 self.assertEqual(self.user.public_repos, 10) | |
63 self.assertEqual(self.user.total_private_repos, 5) | |
64 self.assertEqual(self.user.type, "User") | |
65 self.assertEqual(self.user.url, "https://api.github.com/users/jacquev6") | |
66 | |
67 def testEditWithoutArguments(self): | |
68 self.user.edit() | |
69 | |
70 def testEditWithAllArguments(self): | |
71 self.user.edit("Name edited by PyGithub", "Email edited by PyGithub", "Blog edited by PyGithub", "Company edited by PyGithub", "Location edited by PyGithub", True, "Bio edited by PyGithub") | |
72 self.assertEqual(self.user.name, "Name edited by PyGithub") | |
73 self.assertEqual(self.user.email, "Email edited by PyGithub") | |
74 self.assertEqual(self.user.blog, "Blog edited by PyGithub") | |
75 self.assertEqual(self.user.company, "Company edited by PyGithub") | |
76 self.assertEqual(self.user.location, "Location edited by PyGithub") | |
77 self.assertTrue(self.user.hireable) | |
78 self.assertEqual(self.user.bio, "Bio edited by PyGithub") | |
79 | |
80 def testEmails(self): | |
81 self.assertEqual(self.user.get_emails(), ["vincent@vincent-jacques.net", "github.com@vincent-jacques.net"]) | |
82 self.user.add_to_emails("1@foobar.com", "2@foobar.com") | |
83 self.assertEqual(self.user.get_emails(), ["vincent@vincent-jacques.net", "1@foobar.com", "2@foobar.com", "github.com@vincent-jacques.net"]) | |
84 self.user.remove_from_emails("1@foobar.com", "2@foobar.com") | |
85 self.assertEqual(self.user.get_emails(), ["vincent@vincent-jacques.net", "github.com@vincent-jacques.net"]) | |
86 | |
87 def testFollowing(self): | |
88 nvie = self.g.get_user("nvie") | |
89 self.assertListKeyEqual(self.user.get_following(), lambda u: u.login, ["schacon", "jamis", "chad", "unclebob", "dabrahams", "jnorthrup", "brugidou", "regisb", "walidk", "tanzilli", "fjardon", "r3c", "sdanzan", "vineus", "cjuniet", "gturri", "ant9000", "asquini", "claudyus", "jardon-u", "s-bernard", "kamaradclimber", "Lyloa", "nvie"]) | |
90 self.assertTrue(self.user.has_in_following(nvie)) | |
91 self.user.remove_from_following(nvie) | |
92 self.assertFalse(self.user.has_in_following(nvie)) | |
93 self.user.add_to_following(nvie) | |
94 self.assertTrue(self.user.has_in_following(nvie)) | |
95 self.assertListKeyEqual(self.user.get_followers(), lambda u: u.login, ["jnorthrup", "brugidou", "regisb", "walidk", "afzalkhan", "sdanzan", "vineus", "gturri", "fjardon", "cjuniet", "jardon-u", "kamaradclimber", "L42y"]) | |
96 | |
97 def testWatching(self): | |
98 gitflow = self.g.get_user("nvie").get_repo("gitflow") | |
99 self.assertListKeyEqual(self.user.get_watched(), lambda r: r.name, ["git", "boost.php", "capistrano", "boost.perl", "git-subtree", "git-hg", "homebrew", "celtic_knot", "twisted-intro", "markup", "hub", "gitflow", "murder", "boto", "agit", "d3", "pygit2", "git-pulls", "django_mathlatex", "scrumblr", "developer.github.com", "python-github3", "PlantUML", "bootstrap", "drawnby", "django-socketio", "django-realtime", "playground", "BozoCrack", "FatherBeaver", "PyGithub", "django", "django", "TestPyGithub"]) | |
100 self.assertTrue(self.user.has_in_watched(gitflow)) | |
101 self.user.remove_from_watched(gitflow) | |
102 self.assertFalse(self.user.has_in_watched(gitflow)) | |
103 self.user.add_to_watched(gitflow) | |
104 self.assertTrue(self.user.has_in_watched(gitflow)) | |
105 | |
106 def testStarring(self): | |
107 gitflow = self.g.get_user("nvie").get_repo("gitflow") | |
108 self.assertListKeyEqual(self.user.get_starred(), lambda r: r.name, ["git", "boost.php", "capistrano", "boost.perl", "git-subtree", "git-hg", "homebrew", "celtic_knot", "twisted-intro", "markup", "hub", "gitflow", "murder", "boto", "agit", "d3", "pygit2", "git-pulls", "django_mathlatex", "scrumblr", "developer.github.com", "python-github3", "PlantUML", "bootstrap", "drawnby", "django-socketio", "django-realtime", "playground", "BozoCrack", "FatherBeaver", "amaunet", "django", "django", "moviePlanning", "folly"]) | |
109 self.assertTrue(self.user.has_in_starred(gitflow)) | |
110 self.user.remove_from_starred(gitflow) | |
111 self.assertFalse(self.user.has_in_starred(gitflow)) | |
112 self.user.add_to_starred(gitflow) | |
113 self.assertTrue(self.user.has_in_starred(gitflow)) | |
114 | |
115 def testSubscriptions(self): | |
116 gitflow = self.g.get_user("nvie").get_repo("gitflow") | |
117 self.assertListKeyEqual(self.user.get_subscriptions(), lambda r: r.name, ["gitflow", "ViDE", "Boost.HierarchicalEnum", "QuadProgMm", "DrawSyntax", "DrawTurksHead", "PrivateStuff", "vincent-jacques.net", "Hacking", "C4Planner", "developer.github.com", "PyGithub", "PyGithub", "django", "CinePlanning", "PyGithub", "PyGithub", "PyGithub", "IpMap", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub"]) | |
118 self.assertTrue(self.user.has_in_subscriptions(gitflow)) | |
119 self.user.remove_from_subscriptions(gitflow) | |
120 self.assertFalse(self.user.has_in_subscriptions(gitflow)) | |
121 self.user.add_to_subscriptions(gitflow) | |
122 self.assertTrue(self.user.has_in_subscriptions(gitflow)) | |
123 | |
124 def testGetAuthorizations(self): | |
125 self.assertListKeyEqual(self.user.get_authorizations(), lambda a: a.id, [372294]) | |
126 | |
127 def testCreateRepository(self): | |
128 repo = self.user.create_repo("TestPyGithub") | |
129 self.assertEqual(repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub") | |
130 | |
131 def testCreateRepositoryWithAllArguments(self): | |
132 repo = self.user.create_repo("TestPyGithub", "Repo created by PyGithub", "http://foobar.com", private=False, has_issues=False, has_wiki=False, has_downloads=False) | |
133 self.assertEqual(repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub") | |
134 | |
135 def testCreateRepositoryWithAutoInit(self): | |
136 repo = self.user.create_repo("TestPyGithub", auto_init=True, gitignore_template="Python") | |
137 self.assertEqual(repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub") | |
138 | |
139 def testCreateAuthorizationWithoutArguments(self): | |
140 authorization = self.user.create_authorization() | |
141 self.assertEqual(authorization.id, 372259) | |
142 | |
143 def testCreateAuthorizationWithAllArguments(self): | |
144 authorization = self.user.create_authorization(["repo"], "Note created by PyGithub", "http://vincent-jacques.net/PyGithub") | |
145 self.assertEqual(authorization.id, 372294) | |
146 | |
147 def testCreateAuthorizationWithClientIdAndSecret(self): | |
148 # I don't have a client_id and client_secret so the ReplayData for this test is forged | |
149 authorization = self.user.create_authorization(client_id="01234567890123456789", client_secret="0123456789012345678901234567890123456789") | |
150 self.assertEqual(authorization.id, 372294) | |
151 | |
152 def testCreateGist(self): | |
153 gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")}, "Gist created by PyGithub") | |
154 self.assertEqual(gist.description, "Gist created by PyGithub") | |
155 self.assertEqual(gist.files.keys(), ["foobar.txt"]) | |
156 self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub") | |
157 | |
158 def testCreateGistWithoutDescription(self): | |
159 gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")}) | |
160 self.assertEqual(gist.description, None) | |
161 self.assertEqual(gist.files.keys(), ["foobar.txt"]) | |
162 self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub") | |
163 | |
164 def testCreateKey(self): | |
165 key = self.user.create_key("Key added through PyGithub", "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Mm0RjTNAYFfSCtUpO54usdseroUSIYg5KX4JoseTpqyiB/hqewjYLAdUq/tNIQzrkoEJWSyZrQt0ma7/YCyMYuNGd3DU6q6ZAyBeY3E9RyCiKjO3aTL2VKQGFvBVVmGdxGVSCITRphAcsKc/PF35/fg9XP9S0anMXcEFtdfMHz41SSw+XtE+Vc+6cX9FuI5qUfLGbkv8L1v3g4uw9VXlzq4GfTA+1S7D6mcoGHopAIXFlVr+2RfDKdSURMcB22z41fljO1MW4+zUS/4FyUTpL991es5fcwKXYoiE+x06VJeJJ1Krwx+DZj45uweV6cHXt2JwJEI9fWB6WyBlDejWw== vincent@IDEE") | |
166 self.assertEqual(key.id, 2626650) | |
167 | |
168 def testGetEvents(self): | |
169 self.assertListKeyBegin(self.user.get_events(), lambda e: e.type, ["PushEvent", "IssuesEvent", "IssueCommentEvent", "PushEvent"]) | |
170 | |
171 def testGetOrganizationEvents(self): | |
172 self.assertListKeyBegin(self.user.get_organization_events(self.g.get_organization("BeaverSoftware")), lambda e: e.type, ["CreateEvent", "CreateEvent", "PushEvent", "PushEvent"]) | |
173 | |
174 def testGetGists(self): | |
175 self.assertListKeyEqual(self.user.get_gists(), lambda g: g.id, ["2793505", "2793179", "11cb445f8197e17d303d", "1942384", "dcb7de17e8a52b74541d"]) | |
176 | |
177 def testGetStarredGists(self): | |
178 self.assertListKeyEqual(self.user.get_starred_gists(), lambda g: g.id, ["1942384", "dcb7de17e8a52b74541d"]) | |
179 | |
180 def testGetIssues(self): | |
181 self.assertListKeyEqual(self.user.get_issues(), lambda i: (i.id, i.repository.name), [(4639931, "PyGithub"), (4452000, "PyGithub"), (4356743, "PyGithub"), (3716033, "PyGithub"), (3715946, "PyGithub"), (3643837, "PyGithub"), (3628022, "PyGithub"), (3624595, "PyGithub"), (3624570, "PyGithub"), (3624561, "PyGithub"), (3624556, "PyGithub"), (3619973, "PyGithub"), (3527266, "PyGithub"), (3527245, "PyGithub"), (3527231, "PyGithub")]) | |
182 | |
183 def testGetIssuesWithAllArguments(self): | |
184 requestedByUser = self.user.get_repo("PyGithub").get_label("Requested by user") | |
185 issues = self.user.get_issues("assigned", "closed", [requestedByUser], "comments", "asc", datetime.datetime(2012, 5, 28, 23, 0, 0)) | |
186 self.assertListKeyEqual(issues, lambda i: i.id, [6816576, 8495415, 6889934, 8339699, 8075253, 8033963, 9089893, 9489725, 11746141, 5152384, 5177381, 5783131, 6454054, 6641076, 6653907, 7331214, 9489813, 9776615, 10360280, 4356743, 6583381, 6751469, 8189836, 10758585, 12097154, 12867103, 5191621, 5256315, 6363719, 9209408, 6912733, 9948505, 11503771, 10922412, 11844658, 12566144, 6353712, 9323084, 10379143, 5387373, 12179668, 6911794, 11731917, 6807542, 6780606]) | |
187 | |
188 def testGetUserIssues(self): | |
189 self.assertListKeyEqual(self.user.get_user_issues(), lambda i: i.id, [14447880, 13505356, 12541184, 10586808, 6741461, 6741457, 6727331, 5641572]) | |
190 | |
191 def testGetUserIssuesWithAllArguments(self): | |
192 requestedByUser = self.user.get_repo("PyGithub").get_label("Requested by user") | |
193 issues = self.user.get_user_issues("assigned", "closed", [requestedByUser], "comments", "asc", datetime.datetime(2012, 5, 28, 23, 0, 0)) | |
194 self.assertListKeyEqual(issues, lambda i: i.id, [6816576, 8495415, 6889934, 8339699, 8075253, 8033963, 9089893, 9489725, 11746141, 5152384, 5177381, 5783131, 6454054, 6641076, 6653907, 7331214, 9489813, 9776615, 10360280, 4356743, 6583381, 6751469, 8189836, 10758585, 12097154, 12867103, 5191621, 5256315, 6363719, 9209408, 6912733, 9948505, 11503771, 10922412, 11844658, 12566144, 6353712, 9323084, 10379143, 5387373, 12179668, 6911794, 11731917, 6807542, 6780606]) | |
195 | |
196 def testGetKeys(self): | |
197 self.assertListKeyEqual(self.user.get_keys(), lambda k: k.title, ["vincent@home", "vincent@gandi", "vincent@aws", "vincent@macbook"]) | |
198 | |
199 def testGetOrgs(self): | |
200 self.assertListKeyEqual(self.user.get_orgs(), lambda o: o.login, ["BeaverSoftware"]) | |
201 | |
202 def testGetRepos(self): | |
203 self.assertListKeyEqual(self.user.get_repos(), lambda r: r.name, ["TestPyGithub", "django", "PyGithub", "developer.github.com", "acme-public-website", "C4Planner", "Hacking", "vincent-jacques.net", "Contests", "Candidates", "Tests", "DrawTurksHead", "DrawSyntax", "QuadProgMm", "Boost.HierarchicalEnum", "ViDE"]) | |
204 | |
205 def testGetReposWithArguments(self): | |
206 self.assertListKeyEqual(self.user.get_repos("public", "full_name", "desc"), lambda r: r.name, ["ViDE", "QuadProgMm", "PyGithub", "DrawTurksHead", "DrawSyntax", "django", "developer.github.com", "C4Planner", "Boost.HierarchicalEnum", "acme-public-website"]) | |
207 | |
208 def testCreateFork(self): | |
209 repo = self.user.create_fork(self.g.get_user("nvie").get_repo("gitflow")) | |
210 self.assertEqual(repo.source.full_name, "nvie/gitflow") | |
211 | |
212 def testGetNotification(self): | |
213 notification = self.user.get_notification("8406712") | |
214 self.assertEqual(notification.id, "8406712") | |
215 self.assertEqual(notification.unread, False) | |
216 self.assertEqual(notification.reason, "author") | |
217 self.assertEqual(notification.subject.title, "Feature/coveralls") | |
218 self.assertEqual(notification.subject.type, "PullRequest") | |
219 self.assertEqual(notification.repository.id, 8432784) | |
220 self.assertEqual(notification.updated_at, datetime.datetime(2013, 3, 15, 5, 43, 11)) | |
221 self.assertEqual(notification.url, None) | |
222 self.assertEqual(notification.subject.url, None) | |
223 self.assertEqual(notification.subject.latest_comment_url, None) | |
224 | |
225 def testGetNotifications(self): | |
226 self.assertListKeyEqual(self.user.get_notifications(participating=True), lambda n: n.id, ["8406712"]) | |
227 | |
228 def testGetNotificationsWithOtherArguments(self): | |
229 self.assertListKeyEqual(self.user.get_notifications(all=True), lambda n: n.id, []) | |
230 | |
231 def testGetTeams(self): | |
232 self.assertListKeyEqual(self.user.get_teams(), lambda t: t.name, ["Owners", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries"]) |