Fix tests, add financial verification data fixture
This commit is contained in:
parent
900bb7b7ad
commit
4f9e7c3408
@ -118,3 +118,18 @@ def user_session(monkeypatch, session):
|
|||||||
def pdf_upload():
|
def pdf_upload():
|
||||||
with open(PDF_FILENAME, "rb") as fp:
|
with open(PDF_FILENAME, "rb") as fp:
|
||||||
yield FileStorage(fp, content_type="application/pdf")
|
yield FileStorage(fp, content_type="application/pdf")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def extended_financial_verification_data(pdf_upload):
|
||||||
|
return {
|
||||||
|
"funding_type": "RDTE",
|
||||||
|
"funding_type_other": "other",
|
||||||
|
"clin_0001": "50000",
|
||||||
|
"clin_0003": "13000",
|
||||||
|
"clin_1001": "30000",
|
||||||
|
"clin_1003": "7000",
|
||||||
|
"clin_2001": "30000",
|
||||||
|
"clin_2003": "7000",
|
||||||
|
"task_order": pdf_upload,
|
||||||
|
}
|
||||||
|
@ -121,24 +121,18 @@ request_financial_data = {
|
|||||||
"treasury_code": "00123456",
|
"treasury_code": "00123456",
|
||||||
"ba_code": "024A",
|
"ba_code": "024A",
|
||||||
}
|
}
|
||||||
task_order_financial_data = {
|
|
||||||
"funding_type": "RDTE",
|
|
||||||
"funding_type_other": "other",
|
|
||||||
"clin_0001": 50000,
|
|
||||||
"clin_0003": 13000,
|
|
||||||
"clin_1001": 30000,
|
|
||||||
"clin_1003": 7000,
|
|
||||||
"clin_2001": 30000,
|
|
||||||
"clin_2003": 7000,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def test_update_financial_verification_without_task_order():
|
def test_update_financial_verification_without_task_order(
|
||||||
|
extended_financial_verification_data
|
||||||
|
):
|
||||||
request = RequestFactory.create()
|
request = RequestFactory.create()
|
||||||
financial_data = {**request_financial_data, **task_order_financial_data}
|
financial_data = {**request_financial_data, **extended_financial_verification_data}
|
||||||
Requests.update_financial_verification(request.id, financial_data)
|
Requests.update_financial_verification(request.id, financial_data)
|
||||||
assert request.task_order
|
assert request.task_order
|
||||||
assert request.task_order.clin_0001 == task_order_financial_data["clin_0001"]
|
assert request.task_order.clin_0001 == int(
|
||||||
|
extended_financial_verification_data["clin_0001"]
|
||||||
|
)
|
||||||
assert request.task_order.source == TaskOrderSource.MANUAL
|
assert request.task_order.source == TaskOrderSource.MANUAL
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import urllib
|
import urllib
|
||||||
|
import pytest
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
|
|
||||||
from atst.eda_client import MockEDAClient
|
from atst.eda_client import MockEDAClient
|
||||||
@ -24,16 +25,6 @@ class TestPENumberInForm:
|
|||||||
"treasury_code": "00123456",
|
"treasury_code": "00123456",
|
||||||
"ba_code": "02A",
|
"ba_code": "02A",
|
||||||
}
|
}
|
||||||
extended_data = {
|
|
||||||
"funding_type": "RDTE",
|
|
||||||
"funding_type_other": "other",
|
|
||||||
"clin_0001": "50000",
|
|
||||||
"clin_0003": "13000",
|
|
||||||
"clin_1001": "30000",
|
|
||||||
"clin_1003": "7000",
|
|
||||||
"clin_2001": "30000",
|
|
||||||
"clin_2003": "7000",
|
|
||||||
}
|
|
||||||
|
|
||||||
def _set_monkeypatches(self, monkeypatch):
|
def _set_monkeypatches(self, monkeypatch):
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
@ -50,8 +41,7 @@ class TestPENumberInForm:
|
|||||||
url_kwargs["extended"] = True
|
url_kwargs["extended"] = True
|
||||||
response = client.post(
|
response = client.post(
|
||||||
url_for("requests.financial_verification", **url_kwargs),
|
url_for("requests.financial_verification", **url_kwargs),
|
||||||
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
data=data,
|
||||||
data=urllib.parse.urlencode(data),
|
|
||||||
follow_redirects=False,
|
follow_redirects=False,
|
||||||
)
|
)
|
||||||
return response
|
return response
|
||||||
@ -126,11 +116,12 @@ class TestPENumberInForm:
|
|||||||
|
|
||||||
assert "enter TO information manually" not in response.data.decode()
|
assert "enter TO information manually" not in response.data.decode()
|
||||||
|
|
||||||
def test_submit_extended_financial_form(self, monkeypatch, user_session, client):
|
def test_submit_extended_financial_form(
|
||||||
|
self, monkeypatch, user_session, client, extended_financial_verification_data
|
||||||
|
):
|
||||||
monkeypatch.setattr("atst.domain.requests.Requests.get", lambda i: MOCK_REQUEST)
|
monkeypatch.setattr("atst.domain.requests.Requests.get", lambda i: MOCK_REQUEST)
|
||||||
user_session()
|
user_session()
|
||||||
|
data = {**self.required_data, **extended_financial_verification_data}
|
||||||
data = {**self.required_data, **self.extended_data}
|
|
||||||
data["pe_id"] = MOCK_REQUEST.body["financial_verification"]["pe_id"]
|
data["pe_id"] = MOCK_REQUEST.body["financial_verification"]["pe_id"]
|
||||||
data["task_order_number"] = "1234567"
|
data["task_order_number"] = "1234567"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user