Ejemplo n.º 1
0
def test_signed_request_user_has_authorized_application():
    oauth_token = SignedRequest.User.OAuthToken(token='<token>',
                                                issued_at=datetime.now(),
                                                expires_at=None)

    user = SignedRequest.User(id=1, oauth_token=oauth_token)

    assert user.has_authorized_application is True

    user = SignedRequest.User(id=1, oauth_token=None)

    assert user.has_authorized_application is False
Ejemplo n.º 2
0
def setup_module(module):
    """
    Create a Facebook test user.
    """
    global TEST_SIGNED_REQUEST

    graph = GraphAPI('%s|%s' % (TEST_APPLICATION_ID, TEST_APPLICATION_SECRET))

    user = graph.post('%s/accounts/test-users' % TEST_APPLICATION_ID,
                      installed=True,
                      permissions=['publish_stream, read_stream'])

    TEST_SIGNED_REQUEST = SignedRequest(
        user=SignedRequest.User(id=user['id'],
                                age=range(0, 100),
                                locale='en_US',
                                country='Norway'),
        oauth_token=SignedRequest.OAuthToken(
            token=user['access_token'],
            issued_at=datetime.now(),
            expires_at=None)).generate(TEST_APPLICATION_SECRET)
Ejemplo n.º 3
0
def test_signed_request_user_profile_url():
    user = SignedRequest.User(id=1)

    assert user.profile_url == 'http://facebook.com/1'