MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / testNodeClass

Method testNodeClass

tests/GraphQl.py:119–155  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

117 self.assertEqual(e.exception.data, {"data": {"node": {"__typename": "Discussion"}}})
118
119 def testNodeClass(self):
120 requester = self.g._Github__requester
121 discussion = requester.graphql_node_class(
122 "D_kwDOADYVqs4ATJZD", "title", github.RepositoryDiscussion.RepositoryDiscussion, "Discussion"
123 )
124 self.assertEqual(discussion.title, "Is there a way to search if a string present in default branch?")
125
126 # non-existing node should throw a NOT FOUND exception
127 with self.assertRaises(github.UnknownObjectException) as e:
128 requester.graphql_node_class(
129 "D_abcdefgh", "title", github.RepositoryDiscussion.RepositoryDiscussion, "Discussion"
130 )
131 self.assertEqual(e.exception.status, 404)
132 self.assertEqual(
133 e.exception.data,
134 {
135 "data": {"node": None},
136 "errors": [
137 {
138 "type": "NOT_FOUND",
139 "path": ["node"],
140 "locations": [{"line": 3, "column": 15}],
141 "message": "Could not resolve to a node with the global id of 'D_abcdefgh'",
142 }
143 ],
144 },
145 )
146 self.assertEqual(e.exception.message, "Could not resolve to a node with the global id of 'D_abcdefgh'")
147
148 # wrong type should throw an exception
149 with self.assertRaises(github.GithubException) as e:
150 requester.graphql_node_class(
151 "D_kwDOADYVqs4ATJZD", "login", github.RepositoryDiscussion.RepositoryDiscussion, "User"
152 )
153 self.assertEqual(e.exception.message, "Retrieved User object is of different type: Discussion")
154 self.assertEqual(e.exception.status, 400)
155 self.assertEqual(e.exception.data, {"data": {"node": {"__typename": "Discussion"}}})
156
157 def testQuery(self):
158 requester = self.g._Github__requester

Callers

nothing calls this directly

Calls 1

graphql_node_classMethod · 0.80

Tested by

no test coverage detected