Пример #1
0
def test_authorize_url():
    Trakt.site_url = 'http://mock'

    with Trakt.configuration.client('mock', 'mock'):
        assert_url(
            Trakt['oauth'].authorize_url('urn:ietf:wg:oauth:2.0:oob'),
            '/oauth/authorize', {
                'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob',
                'response_type': 'code',
                'client_id': 'mock'
            })

        assert_url(
            Trakt['oauth'].authorize_url('urn:ietf:wg:oauth:2.0:oob',
                                         state='state',
                                         username='******'),
            '/oauth/authorize', {
                'username': '******',
                'state': 'state',
                'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob',
                'response_type': 'code',
                'client_id': 'mock'
            })

    with pytest.raises(ValueError):
        Trakt['oauth'].authorize_url('urn:ietf:wg:oauth:2.0:oob')
Пример #2
0
def test_authorize_url():
    with Trakt.configuration.client('mock', 'mock'):
        assert_url(Trakt['oauth'].authorize_url('urn:ietf:wg:oauth:2.0:oob'), '/oauth/authorize', {
            'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob',
            'response_type': 'code',
            'client_id': 'mock'
        })

        assert_url(Trakt['oauth'].authorize_url('urn:ietf:wg:oauth:2.0:oob', state='state', username='******'), '/oauth/authorize', {
            'username': '******',
            'state': 'state',

            'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob',
            'response_type': 'code',
            'client_id': 'mock'
        })

    with pytest.raises(ValueError):
        Trakt['oauth'].authorize_url('urn:ietf:wg:oauth:2.0:oob')
Пример #3
0
def test_authorize_url():
    Trakt.site_url = 'http://mock'

    assert_url(Trakt['oauth'].authorize_url('urn:ietf:wg:oauth:2.0:oob'), '/oauth/authorize', {
        'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob',
        'response_type': 'code',
        'client_id': 'mock-client_id'
    })

    assert_url(
        Trakt['oauth'].authorize_url('urn:ietf:wg:oauth:2.0:oob', state='state', username='******'),
        '/oauth/authorize', {
            'username': '******',
            'state': 'state',

            'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob',
            'response_type': 'code',
            'client_id': 'mock-client_id'
        }
    )

    with pytest.raises(ValueError):
        TraktClient()['oauth'].authorize_url('urn:ietf:wg:oauth:2.0:oob')
Пример #4
0
def test_pin_url():
    with Trakt.configuration.app(id=1234):
        assert_url(Trakt['oauth'].pin_url(), '/pin/1234')

    with pytest.raises(ValueError):
        Trakt['oauth'].pin_url()
Пример #5
0
def test_pin_url():
    with Trakt.configuration.app(id=1234):
        assert_url(Trakt['oauth'].pin_url(), '/pin/1234')

    with pytest.raises(ValueError):
        Trakt['oauth'].pin_url()