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

Method testGetAccessTokenWithExpiry

tests/ApplicationOAuth.py:124–147  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

122 self.assertIsNone(access_token.refresh_expires_at)
123
124 def testGetAccessTokenWithExpiry(self):
125 with mock.patch("github.AccessToken.datetime") as dt:
126 dt.now = mock.Mock(return_value=datetime(2023, 6, 7, 12, 0, 0, 123, tzinfo=timezone.utc))
127 access_token = self.app.get_access_token("oauth_code_removed", state="state_removed")
128 # Test string representation
129 self.assertEqual(
130 str(access_token),
131 'AccessToken(type="bearer", token="acces...", scope="", '
132 'refresh_token_expires_in=15811200, refresh_token="refre...", expires_in=28800)',
133 )
134 self.assertEqual(access_token.token, "access_token_removed")
135 self.assertEqual(access_token.type, "bearer")
136 self.assertEqual(access_token.scope, "")
137 self.assertEqual(access_token.expires_in, 28800)
138 self.assertEqual(
139 access_token.expires_at,
140 datetime(2023, 6, 7, 20, 0, 0, 123, tzinfo=timezone.utc),
141 )
142 self.assertEqual(access_token.refresh_token, "refresh_token_removed")
143 self.assertEqual(access_token.refresh_expires_in, 15811200)
144 self.assertEqual(
145 access_token.refresh_expires_at,
146 datetime(2023, 12, 7, 12, 0, 0, 123, tzinfo=timezone.utc),
147 )
148
149 def testRefreshAccessToken(self):
150 access_token = self.app.get_access_token("oauth_code_removed", state="state_removed")

Callers

nothing calls this directly

Calls 2

patchMethod · 0.80
get_access_tokenMethod · 0.45

Tested by

no test coverage detected