def github_session(): github_token = os.environ.get("GITHUB_TOKEN", "faketoken") token = {"access_token": github_token, "token_type": "bearer"} session = OAuth2Session( base_url="https://api.github.com/", blueprint=FakeBlueprint(token), ) return session
def test_oauth2session_unset_access_token(): bp = mock.Mock(token=None) sess = OAuth2Session(client_id="cid", blueprint=bp) assert sess.access_token == None
def test_oauth2session_access_token(): bp = mock.Mock(token=FAKE_OAUTH2_TOKEN) sess = OAuth2Session(client_id="cid", blueprint=bp) assert sess.access_token == "deadbeef"
def test_oauth2session_not_authorized(): bp = mock.Mock(token=None) sess = OAuth2Session(client_id="cid", blueprint=bp) assert sess.authorized == False
def test_oauth2session_authorized(): bp = mock.Mock(token=FAKE_OAUTH2_TOKEN) sess = OAuth2Session(client_id="cid", blueprint=bp) assert sess.authorized == True