def test_get_object_token(self):
    user_PHID = 'PHID-USER-foobarbaz'
    self.phab.user.whoami.return_value = {'phid': user_PHID}
    object_PHID = 'PHID-DREV-abcdef'

    def assert_token_given_called():
        self.phab.token.given.assert_called_with(authorPHIDs=[user_PHID], objectPHIDs=[object_PHID], tokenPHIDs=[])
    self.phab.token.given.return_value = []
    token = self.phab.get_object_token(object_PHID)
    assert_token_given_called()
    self.assertEqual(token, '')
    self.phab.token.given.return_value = [{'authorPHID': user_PHID, 'objectPHID': object_PHID, 'tokenPHID': 'PHID-TOKN-like-1', 'dateCreated': 0}]
    token = self.phab.get_object_token(object_PHID)
    assert_token_given_called()
    self.assertEqual(token, 'PHID-TOKN-like-1')
    self.phab.token.given.return_value = [{'authorPHID': user_PHID, 'objectPHID': object_PHID, 'tokenPHID': 'PHID-TOKN-like-1', 'dateCreated': 0}, {'authorPHID': user_PHID, 'objectPHID': object_PHID, 'tokenPHID': 'PHID-TOKN-like-2', 'dateCreated': 1}]
    token = self.phab.get_object_token(object_PHID)
    assert_token_given_called()
    self.assertEqual(token, 'PHID-TOKN-like-1')
def test_get_object_token(self):
    user_PHID = 'PHID-USER-foobarbaz'
    self.phab.user.whoami.return_value = {'phid': user_PHID}
    object_PHID = 'PHID-DREV-abcdef'

    def assert_token_given_called():
        self.phab.token.given.assert_called_with(authorPHIDs=[user_PHID], objectPHIDs=[object_PHID], tokenPHIDs=[])
    self.phab.token.given.return_value = []
    token = self.phab.get_object_token(object_PHID)
    assert_token_given_called()
    self.assertEqual(token, )
    self.phab.token.given.return_value = [{'authorPHID': user_PHID, 'objectPHID': object_PHID, 'tokenPHID': 'PHID-TOKN-like-1', 'dateCreated': 0}]
    token = self.phab.get_object_token(object_PHID)
    assert_token_given_called()
    self.assertEqual(token, 'PHID-TOKN-like-1')
    self.phab.token.given.return_value = [{'authorPHID': user_PHID, 'objectPHID': object_PHID, 'tokenPHID': 'PHID-TOKN-like-1', 'dateCreated': 0}, {'authorPHID': user_PHID, 'objectPHID': object_PHID, 'tokenPHID': 'PHID-TOKN-like-2', 'dateCreated': 1}]
    token = self.phab.get_object_token(object_PHID)
    assert_token_given_called()
    self.assertEqual(token, 'PHID-TOKN-like-1')