comparison venv/lib/python2.7/site-packages/github/tests/ExposeAllAttributes.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 2013 Vincent Jacques <vincent@vincent-jacques.net> #
6 # #
7 # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
8 # #
9 # PyGithub is free software: you can redistribute it and/or modify it under #
10 # the terms of the GNU Lesser General Public License as published by the Free #
11 # Software Foundation, either version 3 of the License, or (at your option) #
12 # any later version. #
13 # #
14 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
16 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
17 # details. #
18 # #
19 # You should have received a copy of the GNU Lesser General Public License #
20 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
21 # #
22 # ##############################################################################
23
24 import Framework
25
26
27 class ExposeAllAttributes(Framework.TestCase):
28 def testAllClasses(self):
29 authenticatedUser = self.g.get_user()
30 namedUser = self.g.get_user("nvie")
31 repository = authenticatedUser.get_repo("PyGithub")
32 organization = self.g.get_organization("BeaverSoftware")
33 plan = authenticatedUser.plan
34 branch = repository.get_branch("master")
35 commit = repository.get_commit("1292bf0e22c796e91cc3d6e24b544aece8c21f2a")
36 commitStats = commit.stats
37 commitStatus = commit.get_statuses()[0]
38 milestone = repository.get_milestone(17)
39 gist = self.g.get_gist("149016")
40 gistComment = gist.get_comment(4565)
41 gistFile = gist.files[".gitignore"]
42 gistHistoryState = gist.history[0]
43 gitCommit = repository.get_git_commit("be37b8a7f3a68631c32672dcd84d9eba27438ee6")
44 gitAuthor = gitCommit.author
45 gitTree = repository.get_git_tree("6f7c2d8c66d78863f7b91792deaead619799a1ce")
46 gitTreeElement = gitTree.tree[0]
47 gitBlob = repository.get_git_blob("681fb61f1761743a02f5c790f1c762cbfe8cfad1")
48 gitRef = repository.get_git_ref("tags/v1.17.0")
49 gitObject = gitRef.object
50 issue = repository.get_issue(188)
51 issueComment = issue.get_comment(22686536)
52 issueEvent = issue.get_events()[0]
53 issuePullRequest = issue.pull_request
54 gitignoreTemplate = self.g.get_gitignore_template("Python")
55 team = organization.get_team(141487)
56 label = repository.get_label("Bug")
57 pullRequest = repository.get_pull(31)
58 pullRequestComment = pullRequest.get_review_comment(1580134)
59 pullRequestPart = pullRequest.base
60 file = pullRequest.get_files()[0]
61 commitComment = repository.get_comment(3630301)
62 status = self.g.get_api_status()
63 statusMessage = self.g.get_last_api_status_message()
64 rateLimit = self.g.get_rate_limit()
65 rate = rateLimit.rate
66 hook = repository.get_hooks()[0]
67 hookResponse = hook.last_response
68 hookDescription = self.g.get_hooks()[0]
69 comparison = repository.compare("master", "develop")
70 contentFile = repository.get_file_contents("README.rst")
71 permissions = repository.permissions
72 event = repository.get_events()[0]
73 notification = authenticatedUser.get_notification("8406712")
74 notificationSubject = notification.subject
75
76 missingAttributes = self.gatherMissingAttributes([
77 authenticatedUser,
78 # authorization, # Security issue if put as-is in ReplayData
79 # authorizationApplication, # Security issue if put as-is in ReplayData
80 branch,
81 commit,
82 commitComment,
83 commitStats,
84 commitStatus,
85 comparison,
86 contentFile,
87 # download, # Deprecated: https://github.com/blog/1302-goodbye-uploads
88 event,
89 file,
90 gist,
91 gistComment,
92 gistFile,
93 gistHistoryState,
94 gitAuthor,
95 gitBlob,
96 gitCommit,
97 gitignoreTemplate,
98 gitObject,
99 gitRef,
100 # gitTag,
101 gitTree,
102 gitTreeElement,
103 hook,
104 hookDescription,
105 hookResponse,
106 issue,
107 issueComment,
108 issueEvent,
109 issuePullRequest,
110 label,
111 milestone,
112 namedUser,
113 notification,
114 notificationSubject,
115 organization,
116 permissions,
117 plan,
118 pullRequest,
119 pullRequestComment,
120 # pullRequestMergeStatus, # Only obtained when merging a pull request through the API
121 pullRequestPart,
122 rate,
123 rateLimit,
124 repository,
125 # repositoryKey, # Security issue if put as-is in ReplayData
126 status,
127 statusMessage,
128 # tag,
129 team,
130 # userKey, # Security issue if put as-is in ReplayData
131 ])
132
133 for className, attributesMissingInClass in sorted(missingAttributes.iteritems()):
134 for attrName, value in sorted(attributesMissingInClass.iteritems()):
135 print className, attrName, "->", repr(value)
136
137 self.assertEqual(sum(len(attrs) for attrs in missingAttributes.values()), 0)
138
139 def findMissingAttributes(self, obj):
140 if hasattr(obj, "update"):
141 obj.update()
142 className = obj.__class__.__name__
143 missingAttributes = {}
144 for attribute in obj.raw_data:
145 if attribute != "_links":
146 if not hasattr(obj, attribute):
147 missingAttributes[attribute] = obj.raw_data[attribute]
148 return (className, missingAttributes)
149
150 def gatherMissingAttributes(self, objs):
151 allMissingAttributes = dict()
152
153 for obj in objs:
154 className, attributesMissingInClass = self.findMissingAttributes(obj)
155 if len(attributesMissingInClass) > 0:
156 if className not in allMissingAttributes:
157 allMissingAttributes[className] = dict()
158 allMissingAttributes[className].update(attributesMissingInClass)
159
160 return allMissingAttributes