def __init__(self, user, ps, difference, player): self.user = user self.ps = ps self.difference = difference self.player = player self.cred = user.google_credential self.mirror = Mirror.from_credentials(self.cred.all()[0].oauth2credentials())
def _get_mirror(user_id): """ Given a request, build the mirror object by getting the credentials from the DB and building it. @param request: @type request: @return: @rtype: """ try: google_credentials = GoogleCredential.objects.get(user=user_id) except Exception: raise ValueError("User {0} has no GoogleCredential".format(user_id)) oauth_credentials = google_credentials.oauth2credentials() mirror = Mirror.from_credentials(oauth_credentials) google_credentials.refresh(http=mirror.http) return mirror
import unittest from glass.mirror import Mirror, Timeline, TimelineAttachment mirror = Mirror() mirror.get_my_oauth() class TestTimeline(unittest.TestCase): def test_list_timeline(self): pass