def test_redirectsession_rebuilt_auth_called():
    session = RedirectSession()
    with requests_mock.Mocker() as m:
        m.get('http://redirect.com', status_code=302, headers={
            'Location': 'http://newredirect.com'
        })
        m.get('http://newredirect.com', text='redirected!')

        # base assertion, works as intended
        resp = session.get('http://redirect.com').result()
        assert resp.url == 'http://newredirect.com'
        assert resp.text == 'redirected!'

        # Authorization headers unpacked and URL is rewritten
        resp = session.get('http://redirect.com', headers={
            'Authorization': 'api-key foobar'
        }).result()
        assert resp.url == 'http://newredirect.com/?api_key=foobar'
        assert resp.text == 'redirected!'

        # Authorization headers unpacked and URL is rewritten, params saved
        m.get('http://redirect.com', status_code=302, headers={
            'Location': 'http://newredirect.com?param=yep'
        })
        m.get('http://newredirect.com?param=yep', text='param!')
        resp = session.get('http://redirect.com?param=yep', headers={
            'Authorization': 'api-key foobar'
        }).result()
        assert resp.url == 'http://newredirect.com/?param=yep&api_key=foobar'
        assert resp.text == 'param!'
verify our hacking around with Session behavior works
dataset/ETHPy150Open planetlabs/planet-client-python/tests/test_dispatch.py/test_redirectsession_rebuilt_auth_called