Esempio n. 1
0
 def test_initialize(self):
     authenticator = prawcore.UntrustedAuthenticator(REQUESTOR, CLIENT_ID)
     authorizer = prawcore.ImplicitAuthorizer(authenticator, "fake token",
                                              1, "modposts read")
     self.assertEqual("fake token", authorizer.access_token)
     self.assertEqual({"modposts", "read"}, authorizer.scopes)
     self.assertTrue(authorizer.is_valid())
Esempio n. 2
0
 def test_initialize(self):
     authenticator = prawcore.UntrustedAuthenticator(REQUESTOR, CLIENT_ID)
     authorizer = prawcore.ImplicitAuthorizer(authenticator, 'fake token',
                                              1, 'modposts read')
     self.assertEqual('fake token', authorizer.access_token)
     self.assertEqual({'modposts', 'read'}, authorizer.scopes)
     self.assertTrue(authorizer.is_valid())
Esempio n. 3
0
    def test_request__with_invalid_access_token(self):
        authenticator = prawcore.UntrustedAuthenticator(REQUESTOR, CLIENT_ID)
        authorizer = prawcore.ImplicitAuthorizer(authenticator, None, 0, "")
        session = prawcore.Session(authorizer)

        with Betamax(REQUESTOR).use_cassette(
                "Session_request__with_invalid_access_token"):
            session._authorizer.access_token = "invalid"
            self.assertRaises(prawcore.InvalidToken, session.request, "get",
                              "/")
Esempio n. 4
0
 def test_init__with_implicit_authorizer(self):
     authenticator = prawcore.UntrustedAuthenticator(REQUESTOR, CLIENT_ID)
     authorizer = prawcore.ImplicitAuthorizer(authenticator, None, 0, "")
     prawcore.Session(authorizer)