test and update to README

This commit is contained in:
dandds 2018-06-28 10:24:20 -04:00
parent 118a84560a
commit 46016faceb
2 changed files with 16 additions and 5 deletions

View File

@ -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:

View File

@ -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