def test_get_state(): app = Flask('test') multipass = Multipass(app) with app.app_context(): state = get_state(app) assert state.multipass is multipass assert state.app is app assert get_state(app) is state
def test_get_state_explicit(): app = Flask('test') app2 = Flask('test2') multipass = Multipass() multipass.init_app(app) multipass.init_app(app2) # outside app ctx with pytest.raises(RuntimeError): assert get_state().app # explicit app assert get_state(app2).app is app2 # explicit app inside other app context (unlikely) with app.app_context(): assert get_state(app2).app is app2
def provider_map(self): """Returns a read-only mapping between auth and identity providers.""" return get_state().provider_map
def identity_providers(self): """Returns a read-only dict of the active identity providers""" return get_state().identity_providers
def auth_providers(self): """Returns a read-only dict of the active auth providers""" return get_state().auth_providers
def test_get_state_app_not_initialized(): app = Flask('test') with pytest.raises(AssertionError): get_state(app)