Simplify test by removing ThreadPool
This commit is contained in:
parent
e89be59d3e
commit
606bd61d3a
@ -1,7 +1,7 @@
|
||||
import re
|
||||
import pytest
|
||||
import tornado.web
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import tornado.gen
|
||||
|
||||
|
||||
@pytest.mark.gen_test
|
||||
@ -17,19 +17,22 @@ 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):
|
||||
with ThreadPoolExecutor(max_workers=1) as executor:
|
||||
monkeypatch.setattr(
|
||||
"atst.handlers.login.Login._validate_login_token",
|
||||
lambda c,t: executor.submit(lambda: True),
|
||||
)
|
||||
response = yield http_client.fetch(
|
||||
base_url + "/login?bearer-token=abc-123",
|
||||
follow_redirects=False,
|
||||
raise_error=False
|
||||
)
|
||||
assert response.headers["Set-Cookie"].startswith("atst")
|
||||
assert response.headers['Location'] == '/home'
|
||||
assert response.code == 302
|
||||
@tornado.gen.coroutine
|
||||
def _validate_login_token(c, t):
|
||||
return True
|
||||
|
||||
monkeypatch.setattr(
|
||||
"atst.handlers.login.Login._validate_login_token",
|
||||
_validate_login_token
|
||||
)
|
||||
response = yield http_client.fetch(
|
||||
base_url + "/login?bearer-token=abc-123",
|
||||
follow_redirects=False,
|
||||
raise_error=False
|
||||
)
|
||||
assert response.headers["Set-Cookie"].startswith("atst")
|
||||
assert response.headers['Location'] == '/home'
|
||||
assert response.code == 302
|
||||
|
||||
|
||||
@pytest.mark.gen_test
|
||||
|
Loading…
x
Reference in New Issue
Block a user