예제 #1
0
def test_accounts(mock):
    mock.return_value = {
        'data': [{
            'name':
            'Foo Inc.',
            'access_token':
            '...',
            'category':
            'Local business',
            'id':
            '1',
            'perms': [
                'ADMINISTER', 'EDIT_PROFILE', 'CREATE_CONTENT',
                'MODERATE_CONTENT', 'CREATE_ADS', 'BASIC_ADMIN'
            ]
        }]
    }

    with facebook.session('<token>') as session:
        user = session.User('johannes.gorset')

        accounts = user.accounts

        mock.assert_called_with('johannes.gorset/accounts')

        assert_equal('1', accounts[0].page.id)
        assert_equal('Foo Inc.', accounts[0].page.name)
        assert_equal('Local business', accounts[0].page.category)
        assert_equal('...', accounts[0].access_token)
        assert_equal(6, len(accounts[0].permissions))
예제 #2
0
def test_accounts(mock):
    mock.return_value = {
        'data': [
            {
                'name': 'Foo Inc.',
                'access_token': '...',
                'category': 'Local business',
                'id': '1',
                'perms': [
                    'ADMINISTER',
                    'EDIT_PROFILE',
                    'CREATE_CONTENT',
                    'MODERATE_CONTENT',
                    'CREATE_ADS',
                    'BASIC_ADMIN'
                ]
            }
        ]
    }

    with facebook.session('<token>') as session:
        user = session.User('johannes.gorset')

        accounts = user.accounts

        mock.assert_called_with('johannes.gorset/accounts')

        assert_equal('1', accounts[0].page.id)
        assert_equal('Foo Inc.', accounts[0].page.name)
        assert_equal('Local business', accounts[0].page.category)
        assert_equal('...', accounts[0].access_token)
        assert_equal(6, len(accounts[0].permissions))
예제 #3
0
def test_permissions(mock):
    mock.return_value = {
        'data': [{
            'user_location': 1,
            'user_relationships': 1
        }]
    }

    with facebook.session('<token>') as session:
        user = session.User('johannes.gorset')

        permissions = user.permissions

        mock.assert_called_with('johannes.gorset/permissions')

        assert_in('user_location', permissions)
        assert_in('user_relationships', permissions)
예제 #4
0
def test_permissions(mock):
    mock.return_value = {
        'data': [
            {
                'user_location': 1,
                'user_relationships': 1
            }
        ]
    }

    with facebook.session('<token>') as session:
        user = session.User('johannes.gorset')

        permissions = user.permissions

        mock.assert_called_with('johannes.gorset/permissions')

        assert_in('user_location', permissions)
        assert_in('user_relationships', permissions)
예제 #5
0
def test_session(mock):
    mock.return_value = {
        'username': '******',
        'first_name': 'Johannes',
        'last_name': 'Gorset',
        'name': 'Johannes Gorset',
        'locale': 'en_GB',
        'gender': 'male',
        'link': 'http://facebook.com/johannesgorset',
        'id': '586052336'
    }

    oauth_token = 'abcdefghijklmnopqrstuvwxyz'

    with facebook.session(oauth_token) as session:
        user = session.User('johannes.gorset')

        assert_equal(user.oauth_token, oauth_token)

    user = facebook.User('johannes.gorset')
    assert_equal(user.oauth_token, None)
예제 #6
0
def test_session(mock):
    mock.return_value = {
        'username': '******',
        'first_name': 'Johannes',
        'last_name': 'Gorset',
        'name': 'Johannes Gorset',
        'locale': 'en_GB',
        'gender': 'male',
        'link': 'http://facebook.com/johannesgorset',
        'id': '586052336'
    }

    oauth_token = 'abcdefghijklmnopqrstuvwxyz'

    with facebook.session(oauth_token) as session:
        user = session.User('johannes.gorset')

        assert_equal(user.oauth_token, oauth_token)

    user = facebook.User('johannes.gorset')
    assert_equal(user.oauth_token, None)