From 46016faceb058fbc49c14561af272a0a398af0c2 Mon Sep 17 00:00:00 2001 From: dandds Date: Thu, 28 Jun 2018 10:24:20 -0400 Subject: [PATCH] test and update to README --- README.md | 2 ++ tests/test_auth.py | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7b9b4d95..88698d19 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ To enter the virtualenv manually (a la `source .venv/bin/activate`): If you want to automatically load the virtual environment whenever you enter the project directory, take a look at [direnv](https://direnv.net/). An `.envrc` file is included in this repository. direnv will activate and deactivate virtualenvs for you when you enter and leave the directory. +Additionally, ATST requires a redis instance for session management. Have redis installed and running. By default, ATST will try to connect to a redis instance running on localhost on its default port, 6379. + ## Running (development) To start the app and watch for changes: diff --git a/tests/test_auth.py b/tests/test_auth.py index 5769ef85..67a77e45 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -4,7 +4,9 @@ import tornado.web import tornado.gen MOCK_USER = {"user": {"id": "438567dd-25fa-4d83-a8cc-8aa8366cb24a"}} - +@tornado.gen.coroutine +def _fetch_user_info(c, t): + return MOCK_USER @pytest.mark.gen_test def test_redirects_when_not_logged_in(http_client, base_url): @@ -19,10 +21,6 @@ def test_redirects_when_not_logged_in(http_client, base_url): @pytest.mark.gen_test def test_login_with_valid_bearer_token(app, monkeypatch, http_client, base_url): - @tornado.gen.coroutine - def _fetch_user_info(c, t): - return MOCK_USER - monkeypatch.setattr("atst.handlers.login.Login._fetch_user_info", _fetch_user_info) response = yield http_client.fetch( base_url + "/login?bearer-token=abc-123", @@ -52,3 +50,14 @@ def test_login_with_invalid_bearer_token(http_client, base_url): raise_error=False, headers={"Cookie": "bearer-token=anything"}, ) + +@pytest.mark.gen_test +def test_valid_login_creates_session(app, monkeypatch, http_client, base_url): + monkeypatch.setattr("atst.handlers.login.Login._fetch_user_info", _fetch_user_info) + assert len(app.sessions.sessions) == 0 + yield http_client.fetch( + base_url + "/login?bearer-token=abc-123", + follow_redirects=False, + raise_error=False, + ) + assert len(app.sessions.sessions) == 1