示例#1
0
 def setUp(self):
     self.access_token_data = {"client_id": "myclient",
                               "token": "xyz",
                               "scopes": ["foo_read", "foo_write"],
                               "data": {"name": "test"}}
     self.auth_code = AuthorizationCode("myclient", "abc", 100,
                                        "http://localhost",
                                        ["foo_read", "foo_write"],
                                        {"name": "test"})
     
     self.test_store = LocalTokenStore()
示例#2
0
class LocalTokenStoreTestCase(unittest.TestCase):
    def setUp(self):
        self.access_token_data = {"client_id": "myclient",
                                  "token": "xyz",
                                  "scopes": ["foo_read", "foo_write"],
                                  "data": {"name": "test"}}
        self.auth_code = AuthorizationCode("myclient", "abc", 100,
                                           "http://localhost",
                                           ["foo_read", "foo_write"],
                                           {"name": "test"})
        
        self.test_store = LocalTokenStore()
    
    def test_fetch_by_code(self):
        with self.assertRaises(AuthCodeNotFound):
            self.test_store.fetch_by_code("unknown")
    
    def test_save_code_and_fetch_by_code(self):
        success = self.test_store.save_code(self.auth_code)
        self.assertTrue(success)
        
        result = self.test_store.fetch_by_code(self.auth_code.code)
        
        self.assertEqual(result, self.auth_code)
    
    def test_save_token_and_fetch_by_token(self):
        access_token = AccessToken(**self.access_token_data)
        
        success = self.test_store.save_token(access_token)
        self.assertTrue(success)
        
        result = self.test_store.fetch_by_token(access_token.token)
        
        self.assertEqual(result, access_token)