Format project
This commit is contained in:
@@ -22,7 +22,7 @@ class TestPENumberInForm:
|
||||
"office_cor": "WHS",
|
||||
"uii_ids": "1234",
|
||||
"treasury_code": "00123456",
|
||||
"ba_code": "024A"
|
||||
"ba_code": "024A",
|
||||
}
|
||||
extended_data = {
|
||||
"funding_type": "RDTE",
|
||||
@@ -36,8 +36,12 @@ class TestPENumberInForm:
|
||||
}
|
||||
|
||||
def _set_monkeypatches(self, monkeypatch):
|
||||
monkeypatch.setattr("atst.forms.financial.FinancialForm.validate", lambda s: True)
|
||||
monkeypatch.setattr("atst.domain.auth.get_current_user", lambda *args: MOCK_USER)
|
||||
monkeypatch.setattr(
|
||||
"atst.forms.financial.FinancialForm.validate", lambda s: True
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"atst.domain.auth.get_current_user", lambda *args: MOCK_USER
|
||||
)
|
||||
|
||||
def submit_data(self, client, data, extended=False):
|
||||
request = RequestFactory.create(body=MOCK_REQUEST.body)
|
||||
@@ -64,7 +68,7 @@ class TestPENumberInForm:
|
||||
self._set_monkeypatches(monkeypatch)
|
||||
|
||||
data = dict(self.required_data)
|
||||
data['pe_id'] = MOCK_REQUEST.body['financial_verification']['pe_id']
|
||||
data["pe_id"] = MOCK_REQUEST.body["financial_verification"]["pe_id"]
|
||||
|
||||
response = self.submit_data(client, data)
|
||||
|
||||
@@ -76,7 +80,7 @@ class TestPENumberInForm:
|
||||
pe = PENumberFactory.create(number="8675309U", description="sample PE number")
|
||||
|
||||
data = dict(self.required_data)
|
||||
data['pe_id'] = pe.number
|
||||
data["pe_id"] = pe.number
|
||||
|
||||
response = self.submit_data(client, data)
|
||||
|
||||
@@ -87,32 +91,36 @@ class TestPENumberInForm:
|
||||
self._set_monkeypatches(monkeypatch)
|
||||
|
||||
data = dict(self.required_data)
|
||||
data['pe_id'] = ''
|
||||
data["pe_id"] = ""
|
||||
|
||||
response = self.submit_data(client, data)
|
||||
|
||||
assert "There were some errors" in response.data.decode()
|
||||
assert response.status_code == 200
|
||||
|
||||
def test_submit_financial_form_with_invalid_task_order(self, monkeypatch, user_session, client):
|
||||
def test_submit_financial_form_with_invalid_task_order(
|
||||
self, monkeypatch, user_session, client
|
||||
):
|
||||
monkeypatch.setattr("atst.domain.requests.Requests.get", lambda i: MOCK_REQUEST)
|
||||
user_session()
|
||||
|
||||
data = dict(self.required_data)
|
||||
data['pe_id'] = MOCK_REQUEST.body['financial_verification']['pe_id']
|
||||
data['task_order_number'] = '1234'
|
||||
data["pe_id"] = MOCK_REQUEST.body["financial_verification"]["pe_id"]
|
||||
data["task_order_number"] = "1234"
|
||||
|
||||
response = self.submit_data(client, data)
|
||||
|
||||
assert "enter TO information manually" in response.data.decode()
|
||||
|
||||
def test_submit_financial_form_with_valid_task_order(self, monkeypatch, user_session, client):
|
||||
def test_submit_financial_form_with_valid_task_order(
|
||||
self, monkeypatch, user_session, client
|
||||
):
|
||||
monkeypatch.setattr("atst.domain.requests.Requests.get", lambda i: MOCK_REQUEST)
|
||||
user_session()
|
||||
|
||||
data = dict(self.required_data)
|
||||
data['pe_id'] = MOCK_REQUEST.body['financial_verification']['pe_id']
|
||||
data['task_order_number'] = MockEDAClient.MOCK_CONTRACT_NUMBER
|
||||
data["pe_id"] = MOCK_REQUEST.body["financial_verification"]["pe_id"]
|
||||
data["task_order_number"] = MockEDAClient.MOCK_CONTRACT_NUMBER
|
||||
|
||||
response = self.submit_data(client, data)
|
||||
|
||||
@@ -122,9 +130,9 @@ class TestPENumberInForm:
|
||||
monkeypatch.setattr("atst.domain.requests.Requests.get", lambda i: MOCK_REQUEST)
|
||||
user_session()
|
||||
|
||||
data = { **self.required_data, **self.extended_data }
|
||||
data['pe_id'] = MOCK_REQUEST.body['financial_verification']['pe_id']
|
||||
data['task_order_number'] = "1234567"
|
||||
data = {**self.required_data, **self.extended_data}
|
||||
data["pe_id"] = MOCK_REQUEST.body["financial_verification"]["pe_id"]
|
||||
data["task_order_number"] = "1234567"
|
||||
|
||||
response = self.submit_data(client, data, extended=True)
|
||||
|
||||
|
@@ -8,6 +8,7 @@ from tests.assert_util import dict_contains
|
||||
|
||||
ERROR_CLASS = "alert--error"
|
||||
|
||||
|
||||
def test_submit_invalid_request_form(monkeypatch, client, user_session):
|
||||
user_session()
|
||||
response = client.post(
|
||||
@@ -35,7 +36,9 @@ def test_owner_can_view_request(client, user_session):
|
||||
user_session(user)
|
||||
request = RequestFactory.create(creator=user)
|
||||
|
||||
response = client.get("/requests/new/1/{}".format(request.id), follow_redirects=True)
|
||||
response = client.get(
|
||||
"/requests/new/1/{}".format(request.id), follow_redirects=True
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -45,7 +48,9 @@ def test_non_owner_cannot_view_request(client, user_session):
|
||||
user_session(user)
|
||||
request = RequestFactory.create()
|
||||
|
||||
response = client.get("/requests/new/1/{}".format(request.id), follow_redirects=True)
|
||||
response = client.get(
|
||||
"/requests/new/1/{}".format(request.id), follow_redirects=True
|
||||
)
|
||||
|
||||
assert response.status_code == 404
|
||||
|
||||
@@ -56,7 +61,9 @@ def test_ccpo_can_view_request(client, user_session):
|
||||
user_session(user)
|
||||
request = RequestFactory.create()
|
||||
|
||||
response = client.get("/requests/new/1/{}".format(request.id), follow_redirects=True)
|
||||
response = client.get(
|
||||
"/requests/new/1/{}".format(request.id), follow_redirects=True
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -80,7 +87,9 @@ def test_creator_info_is_autopopulated(monkeypatch, client, user_session):
|
||||
assert "initial-value='{}'".format(user.email) in body
|
||||
|
||||
|
||||
def test_creator_info_is_autopopulated_for_new_request(monkeypatch, client, user_session):
|
||||
def test_creator_info_is_autopopulated_for_new_request(
|
||||
monkeypatch, client, user_session
|
||||
):
|
||||
user = UserFactory.create()
|
||||
user_session(user)
|
||||
|
||||
@@ -103,6 +112,7 @@ def test_non_creator_info_is_not_autopopulated(monkeypatch, client, user_session
|
||||
assert not user.last_name in body
|
||||
assert not user.email in body
|
||||
|
||||
|
||||
def test_am_poc_causes_poc_to_be_autopopulated(client, user_session):
|
||||
creator = UserFactory.create()
|
||||
user_session(creator)
|
||||
@@ -124,7 +134,7 @@ def test_not_am_poc_requires_poc_info_to_be_completed(client, user_session):
|
||||
"/requests/new/3/{}".format(request.id),
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
||||
data="am_poc=no",
|
||||
follow_redirects=True
|
||||
follow_redirects=True,
|
||||
)
|
||||
assert ERROR_CLASS in response.data.decode()
|
||||
|
||||
@@ -156,7 +166,7 @@ def test_poc_details_can_be_autopopulated_on_new_request(client, user_session):
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
||||
data="am_poc=yes",
|
||||
)
|
||||
request_id = response.headers["Location"].split('/')[-1]
|
||||
request_id = response.headers["Location"].split("/")[-1]
|
||||
request = Requests.get(request_id)
|
||||
|
||||
assert request.body["primary_poc"]["dodid_poc"] == creator.dod_id
|
||||
@@ -165,27 +175,31 @@ def test_poc_details_can_be_autopopulated_on_new_request(client, user_session):
|
||||
def test_poc_autofill_checks_information_about_you_form_first(client, user_session):
|
||||
creator = UserFactory.create()
|
||||
user_session(creator)
|
||||
request = RequestFactory.create(creator=creator, body={
|
||||
"information_about_you": {
|
||||
"fname_request": "Alice",
|
||||
"lname_request": "Adams",
|
||||
"email_request": "alice.adams@mail.mil"
|
||||
}
|
||||
})
|
||||
poc_input = {
|
||||
"am_poc": "yes",
|
||||
}
|
||||
request = RequestFactory.create(
|
||||
creator=creator,
|
||||
body={
|
||||
"information_about_you": {
|
||||
"fname_request": "Alice",
|
||||
"lname_request": "Adams",
|
||||
"email_request": "alice.adams@mail.mil",
|
||||
}
|
||||
},
|
||||
)
|
||||
poc_input = {"am_poc": "yes"}
|
||||
client.post(
|
||||
"/requests/new/3/{}".format(request.id),
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
||||
data=urlencode(poc_input),
|
||||
)
|
||||
request = Requests.get(request.id)
|
||||
assert dict_contains(request.body["primary_poc"], {
|
||||
"fname_poc": "Alice",
|
||||
"lname_poc": "Adams",
|
||||
"email_poc": "alice.adams@mail.mil"
|
||||
})
|
||||
assert dict_contains(
|
||||
request.body["primary_poc"],
|
||||
{
|
||||
"fname_poc": "Alice",
|
||||
"lname_poc": "Adams",
|
||||
"email_poc": "alice.adams@mail.mil",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_can_review_data(user_session, client):
|
||||
|
@@ -28,11 +28,16 @@ def test_submit_autoapproved_reviewed_request(monkeypatch, client, user_session)
|
||||
user_session()
|
||||
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", RequestStatus.PENDING_FINANCIAL_VERIFICATION)
|
||||
monkeypatch.setattr(
|
||||
"atst.models.request.Request.status",
|
||||
RequestStatus.PENDING_FINANCIAL_VERIFICATION,
|
||||
)
|
||||
response = client.post(
|
||||
"/requests/submit/1",
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
||||
data="",
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert "/requests?modal=pendingFinancialVerification" in response.headers["Location"]
|
||||
assert (
|
||||
"/requests?modal=pendingFinancialVerification" in response.headers["Location"]
|
||||
)
|
||||
|
Reference in New Issue
Block a user