def test_unauthorized_debug_mode(self, active_config, env): from werkzeug.exceptions import Unauthorized from dallinger.experiment_server.dashboard import unauthorized active_config.set("mode", "debug") with pytest.raises(Unauthorized): unauthorized()
def test_unauthorized_redirects(self, active_config, env): from dallinger.experiment_server.dashboard import unauthorized active_config.set("mode", "sandbox") with mock.patch("dallinger.experiment_server.dashboard.request"): with mock.patch( "dallinger.experiment_server.dashboard.make_login_url" ) as make_login_url: make_login_url.return_value = "http://www.example.net/login" response = unauthorized() assert response.status_code == 302 assert response.location == "http://www.example.net/login" make_login_url.assert_called_once_with("dashboard.login", next_url=mock.ANY)