update and fix some tests from rebase
This commit is contained in:
parent
84c228ec2e
commit
7f5f02985b
@ -6,6 +6,7 @@ from atst.forms.request import RequestForm
|
|||||||
from atst.forms.org import OrgForm
|
from atst.forms.org import OrgForm
|
||||||
from atst.forms.poc import POCForm
|
from atst.forms.poc import POCForm
|
||||||
from atst.forms.review import ReviewForm
|
from atst.forms.review import ReviewForm
|
||||||
|
from atst.domain.requests import Requests
|
||||||
|
|
||||||
|
|
||||||
class RequestNew(BaseHandler):
|
class RequestNew(BaseHandler):
|
||||||
|
@ -4,5 +4,8 @@
|
|||||||
|
|
||||||
source "$(dirname "${0}")"/../script/include/global_header.inc.sh
|
source "$(dirname "${0}")"/../script/include/global_header.inc.sh
|
||||||
|
|
||||||
# Run the bootstrap script
|
# Enable DB migration
|
||||||
source ./script/bootstrap
|
MIGRATE_DB="true"
|
||||||
|
|
||||||
|
# Run the shared update script
|
||||||
|
source ./script/include/run_update
|
||||||
|
@ -40,7 +40,7 @@ class TestPENumberInForm:
|
|||||||
@tornado.gen.coroutine
|
@tornado.gen.coroutine
|
||||||
def submit_data(self, http_client, base_url, data):
|
def submit_data(self, http_client, base_url, data):
|
||||||
response = yield http_client.fetch(
|
response = yield http_client.fetch(
|
||||||
base_url + "/requests/verify/{}".format(MOCK_REQUEST["id"]),
|
base_url + "/requests/verify/{}".format(MOCK_REQUEST.id),
|
||||||
method="POST",
|
method="POST",
|
||||||
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
||||||
body=urllib.parse.urlencode(data),
|
body=urllib.parse.urlencode(data),
|
||||||
|
@ -3,7 +3,6 @@ import pytest
|
|||||||
import tornado
|
import tornado
|
||||||
import urllib
|
import urllib
|
||||||
from tests.mocks import MOCK_USER
|
from tests.mocks import MOCK_USER
|
||||||
from tests.factories import RequestFactory
|
|
||||||
|
|
||||||
ERROR_CLASS = "alert--error"
|
ERROR_CLASS = "alert--error"
|
||||||
MOCK_REQUEST = RequestFactory.create(
|
MOCK_REQUEST = RequestFactory.create(
|
||||||
|
@ -1,19 +1,26 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
import tornado
|
||||||
from tests.mocks import MOCK_USER
|
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
|
@pytest.mark.gen_test
|
||||||
def test_submit_reviewed_request(monkeypatch, http_client, base_url):
|
def test_submit_reviewed_request(monkeypatch, http_client, base_url):
|
||||||
monkeypatch.setattr(
|
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(
|
monkeypatch.setattr(
|
||||||
"atst.handlers.request_submit.RequestsSubmit.check_xsrf_cookie", lambda s: True
|
"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
|
# this just needs to send a known invalid form value
|
||||||
response = yield http_client.fetch(
|
response = yield http_client.fetch(
|
||||||
base_url + "/requests/submit/1",
|
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"},
|
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
||||||
body="",
|
body="",
|
||||||
raise_error=False,
|
raise_error=False,
|
||||||
follow_redirects=False
|
follow_redirects=False,
|
||||||
)
|
)
|
||||||
assert response.headers["Location"] == "/requests"
|
assert response.headers["Location"] == "/requests"
|
||||||
|
|
||||||
@ -29,14 +36,15 @@ def test_submit_reviewed_request(monkeypatch, http_client, base_url):
|
|||||||
@pytest.mark.gen_test
|
@pytest.mark.gen_test
|
||||||
def test_submit_autoapproved_reviewed_request(monkeypatch, http_client, base_url):
|
def test_submit_autoapproved_reviewed_request(monkeypatch, http_client, base_url):
|
||||||
monkeypatch.setattr(
|
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(
|
monkeypatch.setattr(
|
||||||
"atst.handlers.request_submit.RequestsSubmit.check_xsrf_cookie", lambda s: True
|
"atst.handlers.request_submit.RequestsSubmit.check_xsrf_cookie", lambda s: True
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr("atst.domain.requests.Requests.get", _mock_func)
|
||||||
"tests.mocks.MOCK_REQUEST", APPROVED_MOCK_REQUEST
|
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
|
# this just needs to send a known invalid form value
|
||||||
response = yield http_client.fetch(
|
response = yield http_client.fetch(
|
||||||
base_url + "/requests/submit/1",
|
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"},
|
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
||||||
body="",
|
body="",
|
||||||
raise_error=False,
|
raise_error=False,
|
||||||
follow_redirects=False
|
follow_redirects=False,
|
||||||
)
|
)
|
||||||
assert response.headers["Location"] == "/requests?modal=True"
|
assert response.headers["Location"] == "/requests?modal=True"
|
||||||
|
@ -2,6 +2,7 @@ import tornado.gen
|
|||||||
from tornado.httpclient import HTTPRequest, HTTPResponse
|
from tornado.httpclient import HTTPRequest, HTTPResponse
|
||||||
|
|
||||||
from atst.api_client import ApiClient
|
from atst.api_client import ApiClient
|
||||||
|
from tests.factories import RequestFactory
|
||||||
|
|
||||||
|
|
||||||
MOCK_USER = {
|
MOCK_USER = {
|
||||||
@ -10,6 +11,14 @@ MOCK_USER = {
|
|||||||
"first_name": "Fake",
|
"first_name": "Fake",
|
||||||
"last_name": "User",
|
"last_name": "User",
|
||||||
}
|
}
|
||||||
|
MOCK_REQUEST = RequestFactory.create(
|
||||||
|
creator=MOCK_USER["id"],
|
||||||
|
body={
|
||||||
|
"financial_verification": {
|
||||||
|
"pe_id": "0203752A",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MockApiClient(ApiClient):
|
class MockApiClient(ApiClient):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user