示例#1
0
 def test_oauth_access_token_for_creates_nonexistent_token(self):
     # If there's no token for user/consumer key/permission/context,
     # one is created.
     person = self.factory.makePerson()
     self.assertEqual(person.oauth_access_tokens.count(), 0)
     oauth_access_token_for(self.consumer.key, person,
                            OAuthPermission.WRITE_PUBLIC, self.context)
     self.assertEqual(person.oauth_access_tokens.count(), 1)
示例#2
0
 def test_oauth_access_token_for_creates_nonexistent_token(self):
     # If there's no token for user/consumer key/permission/context,
     # one is created.
     person = self.factory.makePerson()
     self.assertEquals(person.oauth_access_tokens.count(), 0)
     oauth_access_token_for(
         self.consumer.key, person, OAuthPermission.WRITE_PUBLIC,
         self.context)
     self.assertEquals(person.oauth_access_tokens.count(), 1)
示例#3
0
    def test_oauth_access_token_for_retrieves_existing_token(self):
        # If there's already a token for a
        # user/consumer key/permission/context, it's retrieved.
        person = self.factory.makePerson()
        self.assertEquals(person.oauth_access_tokens.count(), 0)
        access_token = oauth_access_token_for(
            self.consumer.key, person, OAuthPermission.WRITE_PUBLIC,
            self.context)
        self.assertEquals(person.oauth_access_tokens.count(), 1)

        access_token_2 = oauth_access_token_for(
            access_token.consumer.key, access_token.person,
            access_token.permission, access_token.context)
        self.assertEquals(person.oauth_access_tokens.count(), 1)
        self.assertTrue(sameProxiedObjects(access_token, access_token_2))
示例#4
0
 def test_oauth_access_token_string_permission(self):
     """You can pass in a string instead of an OAuthPermission."""
     access_token, _ = oauth_access_token_for(self.consumer.key,
                                              self.person, 'WRITE_PUBLIC')
     self.assertEqual(access_token.permission, AccessLevel.WRITE_PUBLIC)
示例#5
0
 def test_oauth_access_token_string_permission(self):
     """You can pass in a string instead of an OAuthPermission."""
     access_token = oauth_access_token_for(
         self.consumer.key, self.person, 'WRITE_PUBLIC')
     self.assertEqual(access_token.permission, AccessLevel.WRITE_PUBLIC)