update and fix some tests from rebase
This commit is contained in:
@@ -1,19 +1,26 @@
|
||||
import pytest
|
||||
import tornado
|
||||
from tests.mocks import MOCK_USER
|
||||
from tests.factories import RequestFactory
|
||||
|
||||
|
||||
@tornado.gen.coroutine
|
||||
def _mock_func(*args, **kwargs):
|
||||
return RequestFactory.create()
|
||||
|
||||
ERROR_CLASS = "usa-input-error-message"
|
||||
APPROVED_MOCK_REQUEST = {
|
||||
"status": "approved"
|
||||
}
|
||||
|
||||
@pytest.mark.gen_test
|
||||
def test_submit_reviewed_request(monkeypatch, http_client, base_url):
|
||||
monkeypatch.setattr(
|
||||
"atst.handlers.request_submit.RequestsSubmit.get_current_user", lambda s: MOCK_USER
|
||||
"atst.handlers.request_submit.RequestsSubmit.get_current_user",
|
||||
lambda s: MOCK_USER,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"atst.handlers.request_submit.RequestsSubmit.check_xsrf_cookie", lambda s: True
|
||||
)
|
||||
monkeypatch.setattr("atst.domain.requests.Requests.get", _mock_func)
|
||||
monkeypatch.setattr("atst.domain.requests.Requests.submit", _mock_func)
|
||||
monkeypatch.setattr("atst.models.request.Request.status", "pending")
|
||||
# this just needs to send a known invalid form value
|
||||
response = yield http_client.fetch(
|
||||
base_url + "/requests/submit/1",
|
||||
@@ -21,7 +28,7 @@ def test_submit_reviewed_request(monkeypatch, http_client, base_url):
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
||||
body="",
|
||||
raise_error=False,
|
||||
follow_redirects=False
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert response.headers["Location"] == "/requests"
|
||||
|
||||
@@ -29,14 +36,15 @@ def test_submit_reviewed_request(monkeypatch, http_client, base_url):
|
||||
@pytest.mark.gen_test
|
||||
def test_submit_autoapproved_reviewed_request(monkeypatch, http_client, base_url):
|
||||
monkeypatch.setattr(
|
||||
"atst.handlers.request_submit.RequestsSubmit.get_current_user", lambda s: MOCK_USER
|
||||
"atst.handlers.request_submit.RequestsSubmit.get_current_user",
|
||||
lambda s: MOCK_USER,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"atst.handlers.request_submit.RequestsSubmit.check_xsrf_cookie", lambda s: True
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"tests.mocks.MOCK_REQUEST", APPROVED_MOCK_REQUEST
|
||||
)
|
||||
monkeypatch.setattr("atst.domain.requests.Requests.get", _mock_func)
|
||||
monkeypatch.setattr("atst.domain.requests.Requests.submit", _mock_func)
|
||||
monkeypatch.setattr("atst.models.request.Request.status", "approved")
|
||||
# this just needs to send a known invalid form value
|
||||
response = yield http_client.fetch(
|
||||
base_url + "/requests/submit/1",
|
||||
@@ -44,6 +52,6 @@ def test_submit_autoapproved_reviewed_request(monkeypatch, http_client, base_url
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
||||
body="",
|
||||
raise_error=False,
|
||||
follow_redirects=False
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert response.headers["Location"] == "/requests?modal=True"
|
||||
|
Reference in New Issue
Block a user