update and fix some tests from rebase

This commit is contained in:
dandds
2018-07-27 15:15:44 -04:00
committed by richard-dds
parent 5f2ffe57b8
commit 0179a22827
6 changed files with 35 additions and 15 deletions

View File

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