def test_if_needs_oauth_redirect_not_logged_in(monkeypatch): monkeypatch.setitem(lexeme_forms.app.config, 'oauth', {}) monkeypatch.setattr(lexeme_forms, 'consumer_token', mwoauth.ConsumerToken('test key', 'test secret'), raising=False) monkeypatch.setattr(mwoauth, 'initiate', lambda mw_uri, consumer_token, user_agent: ('test redirect', mwoauth.RequestToken('test key', 'test secret'))) with lexeme_forms.app.test_request_context() as context: response = lexeme_forms.if_needs_oauth_redirect() assert response is not None assert str(response.status_code).startswith('3')
def test_if_needs_oauth_redirect_logged_in(monkeypatch): monkeypatch.setitem(lexeme_forms.app.config, 'oauth', {}) with lexeme_forms.app.test_request_context() as context: context.session['oauth_access_token'] = 'test token' assert lexeme_forms.if_needs_oauth_redirect() is None
def test_if_needs_oauth_redirect_not_configured(monkeypatch): monkeypatch.delitem(lexeme_forms.app.config, 'oauth', raising=False) assert lexeme_forms.if_needs_oauth_redirect() is None