put requests workflow tests behind a feature toggle

This commit is contained in:
dandds
2019-01-07 16:03:40 -05:00
parent 3612fcca6c
commit 08806eed24
18 changed files with 129 additions and 33 deletions

View File

@@ -1,3 +1,4 @@
import pytest
import re
from flask import url_for
@@ -6,6 +7,7 @@ from atst.models.request_status_event import RequestStatus
from tests.factories import RequestFactory, LegacyTaskOrderFactory, UserFactory
@pytest.mark.requests_workflow
def test_can_show_financial_data(client, user_session):
user = UserFactory.create()
user_session(user)
@@ -24,6 +26,7 @@ def test_can_show_financial_data(client, user_session):
assert re.search(r">\s+Financial Verification\s+<", body)
@pytest.mark.requests_workflow
def test_can_not_show_financial_data(client, user_session):
user = UserFactory.create()
user_session(user)

View File

@@ -1,7 +1,9 @@
import pytest
from tests.factories import UserFactory, RequestFactory
from atst.models.request_status_event import RequestStatus
@pytest.mark.requests_workflow
def test_creator_pending_finver(client, user_session):
request = RequestFactory.create_with_status(
RequestStatus.PENDING_FINANCIAL_VERIFICATION
@@ -13,6 +15,7 @@ def test_creator_pending_finver(client, user_session):
assert "verify" in response.location
@pytest.mark.requests_workflow
def test_creator_pending_finver_changes(client, user_session):
request = RequestFactory.create_with_status(
RequestStatus.CHANGES_REQUESTED_TO_FINVER
@@ -24,6 +27,7 @@ def test_creator_pending_finver_changes(client, user_session):
assert "verify" in response.location
@pytest.mark.requests_workflow
def test_creator_approved(client, user_session):
request = RequestFactory.create_with_status(RequestStatus.APPROVED)
user_session(request.creator)
@@ -33,6 +37,7 @@ def test_creator_approved(client, user_session):
assert "details" in response.location
@pytest.mark.requests_workflow
def test_creator_approved(client, user_session):
request = RequestFactory.create_with_status(RequestStatus.STARTED)
user_session(request.creator)
@@ -42,6 +47,7 @@ def test_creator_approved(client, user_session):
assert "new" in response.location
@pytest.mark.requests_workflow
def test_ccpo(client, user_session):
ccpo = UserFactory.from_atat_role("ccpo")
request = RequestFactory.create_with_status(RequestStatus.STARTED)

View File

@@ -1,3 +1,4 @@
import pytest
import datetime
import re
from tests.factories import (
@@ -17,6 +18,7 @@ from tests.assert_util import dict_contains
ERROR_CLASS = "alert--error"
@pytest.mark.requests_workflow
def test_submit_invalid_request_form(monkeypatch, client, user_session):
user_session()
response = client.post(
@@ -27,6 +29,7 @@ def test_submit_invalid_request_form(monkeypatch, client, user_session):
assert re.search(ERROR_CLASS, response.data.decode())
@pytest.mark.requests_workflow
def test_submit_valid_request_form(monkeypatch, client, user_session):
user_session()
monkeypatch.setattr(
@@ -41,6 +44,7 @@ def test_submit_valid_request_form(monkeypatch, client, user_session):
assert "/requests/new/2" in response.headers.get("Location")
@pytest.mark.requests_workflow
def test_owner_can_view_request(client, user_session):
user = UserFactory.create()
user_session(user)
@@ -53,6 +57,7 @@ def test_owner_can_view_request(client, user_session):
assert response.status_code == 200
@pytest.mark.requests_workflow
def test_non_owner_cannot_view_request(client, user_session):
user = UserFactory.create()
user_session(user)
@@ -65,6 +70,7 @@ def test_non_owner_cannot_view_request(client, user_session):
assert response.status_code == 404
@pytest.mark.requests_workflow
def test_ccpo_can_view_request(client, user_session):
ccpo = Roles.get("ccpo")
user = UserFactory.create(atat_role=ccpo)
@@ -78,6 +84,7 @@ def test_ccpo_can_view_request(client, user_session):
assert response.status_code == 200
@pytest.mark.requests_workflow
def test_nonexistent_request(client, user_session):
user_session()
response = client.get("/requests/new/1/foo", follow_redirects=True)
@@ -85,6 +92,7 @@ def test_nonexistent_request(client, user_session):
assert response.status_code == 404
@pytest.mark.requests_workflow
def test_creator_info_is_autopopulated_for_existing_request(
monkeypatch, client, user_session
):
@@ -108,6 +116,7 @@ def test_creator_info_is_autopopulated_for_existing_request(
assert "initial-value='{}'".format(value) in body
@pytest.mark.requests_workflow
def test_creator_info_is_autopopulated_for_new_request(
monkeypatch, client, user_session
):
@@ -121,6 +130,7 @@ def test_creator_info_is_autopopulated_for_new_request(
assert "initial-value='{}'".format(user.email) in body
@pytest.mark.requests_workflow
def test_non_creator_info_is_not_autopopulated(monkeypatch, client, user_session):
user = UserFactory.create()
creator = UserFactory.create()
@@ -134,6 +144,7 @@ def test_non_creator_info_is_not_autopopulated(monkeypatch, client, user_session
assert not user.email in body
@pytest.mark.requests_workflow
def test_am_poc_causes_poc_to_be_autopopulated(client, user_session):
creator = UserFactory.create()
user_session(creator)
@@ -147,6 +158,7 @@ def test_am_poc_causes_poc_to_be_autopopulated(client, user_session):
assert request.body["primary_poc"]["dodid_poc"] == creator.dod_id
@pytest.mark.requests_workflow
def test_not_am_poc_requires_poc_info_to_be_completed(client, user_session):
creator = UserFactory.create()
user_session(creator)
@@ -160,6 +172,7 @@ def test_not_am_poc_requires_poc_info_to_be_completed(client, user_session):
assert ERROR_CLASS in response.data.decode()
@pytest.mark.requests_workflow
def test_not_am_poc_allows_user_to_fill_in_poc_info(client, user_session):
creator = UserFactory.create()
user_session(creator)
@@ -179,6 +192,7 @@ def test_not_am_poc_allows_user_to_fill_in_poc_info(client, user_session):
assert ERROR_CLASS not in response.data.decode()
@pytest.mark.requests_workflow
def test_poc_details_can_be_autopopulated_on_new_request(client, user_session):
creator = UserFactory.create()
user_session(creator)
@@ -193,6 +207,7 @@ def test_poc_details_can_be_autopopulated_on_new_request(client, user_session):
assert request.body["primary_poc"]["dodid_poc"] == creator.dod_id
@pytest.mark.requests_workflow
def test_poc_autofill_checks_information_about_you_form_first(client, user_session):
creator = UserFactory.create()
user_session(creator)
@@ -221,6 +236,7 @@ def test_poc_autofill_checks_information_about_you_form_first(client, user_sessi
)
@pytest.mark.requests_workflow
def test_can_review_data(user_session, client):
creator = UserFactory.create()
user_session(creator)
@@ -232,6 +248,7 @@ def test_can_review_data(user_session, client):
assert request.body["information_about_you"]["email_request"] in body
@pytest.mark.requests_workflow
def test_displays_ccpo_review_comment(user_session, client):
creator = UserFactory.create()
ccpo = UserFactory.from_atat_role("ccpo")

View File

@@ -8,6 +8,7 @@ def _mock_func(*args, **kwargs):
return RequestFactory.create()
@pytest.mark.requests_workflow
def test_submit_reviewed_request(monkeypatch, client, user_session):
user_session()
monkeypatch.setattr("atst.domain.requests.Requests.get", _mock_func)
@@ -24,6 +25,7 @@ def test_submit_reviewed_request(monkeypatch, client, user_session):
assert "modal=pendingCCPOAcceptance" in response.headers["Location"]
@pytest.mark.requests_workflow
def test_submit_autoapproved_reviewed_request(monkeypatch, client, user_session):
user_session()
monkeypatch.setattr("atst.domain.requests.Requests.get", _mock_func)

View File

@@ -1,3 +1,4 @@
import pytest
import os
from flask import url_for
@@ -14,6 +15,7 @@ from tests.factories import (
)
@pytest.mark.requests_workflow
def test_ccpo_can_view_approval(user_session, client):
ccpo = Roles.get("ccpo")
user = UserFactory.create(atat_role=ccpo)
@@ -24,6 +26,7 @@ def test_ccpo_can_view_approval(user_session, client):
assert response.status_code == 200
@pytest.mark.requests_workflow
def test_ccpo_prepopulated_as_mission_owner(user_session, client):
user = UserFactory.from_atat_role("ccpo")
user_session(user)
@@ -36,6 +39,7 @@ def test_ccpo_prepopulated_as_mission_owner(user_session, client):
assert user.last_name in body
@pytest.mark.requests_workflow
def test_non_ccpo_cannot_view_approval(user_session, client):
user = UserFactory.create()
user_session(user)
@@ -45,6 +49,7 @@ def test_non_ccpo_cannot_view_approval(user_session, client):
assert response.status_code == 404
@pytest.mark.requests_workflow
def prepare_request_pending_approval(creator, pdf_attachment=None):
legacy_task_order = LegacyTaskOrderFactory.create(
number="abc123", pdf=pdf_attachment
@@ -56,6 +61,7 @@ def prepare_request_pending_approval(creator, pdf_attachment=None):
)
@pytest.mark.requests_workflow
def test_ccpo_sees_pdf_link(user_session, client, pdf_upload):
ccpo = UserFactory.from_atat_role("ccpo")
user_session(ccpo)
@@ -70,6 +76,7 @@ def test_ccpo_sees_pdf_link(user_session, client, pdf_upload):
assert download_url in body
@pytest.mark.requests_workflow
def test_ccpo_does_not_see_pdf_link_if_no_pdf(user_session, client, pdf_upload):
ccpo = UserFactory.from_atat_role("ccpo")
user_session(ccpo)
@@ -83,6 +90,7 @@ def test_ccpo_does_not_see_pdf_link_if_no_pdf(user_session, client, pdf_upload):
assert download_url not in body
@pytest.mark.requests_workflow
def test_task_order_download(app, client, user_session, pdf_upload):
user = UserFactory.create()
user_session(user)
@@ -108,6 +116,7 @@ def test_task_order_download(app, client, user_session, pdf_upload):
assert response.data == pdf_content
@pytest.mark.requests_workflow
def test_task_order_download_does_not_exist(client, user_session):
user = UserFactory.create()
user_session(user)
@@ -118,6 +127,7 @@ def test_task_order_download_does_not_exist(client, user_session):
assert response.status_code == 404
@pytest.mark.requests_workflow
def test_can_submit_request_approval(client, user_session):
user = UserFactory.from_atat_role("ccpo")
user_session(user)
@@ -133,6 +143,7 @@ def test_can_submit_request_approval(client, user_session):
assert request.status == RequestStatus.PENDING_FINANCIAL_VERIFICATION
@pytest.mark.requests_workflow
def test_can_submit_request_denial(client, user_session):
user = UserFactory.from_atat_role("ccpo")
user_session(user)
@@ -148,6 +159,7 @@ def test_can_submit_request_denial(client, user_session):
assert request.status == RequestStatus.CHANGES_REQUESTED
@pytest.mark.requests_workflow
def test_ccpo_user_can_comment_on_request(client, user_session):
user = UserFactory.from_atat_role("ccpo")
user_session(user)
@@ -167,6 +179,7 @@ def test_ccpo_user_can_comment_on_request(client, user_session):
assert request.internal_comments[0].text == comment_text
@pytest.mark.requests_workflow
def test_comment_text_is_required(client, user_session):
user = UserFactory.from_atat_role("ccpo")
user_session(user)
@@ -184,6 +197,7 @@ def test_comment_text_is_required(client, user_session):
assert len(request.internal_comments) == 0
@pytest.mark.requests_workflow
def test_other_user_cannot_comment_on_request(client, user_session):
user = UserFactory.create()
user_session(user)

View File

@@ -69,6 +69,7 @@ FalseValidator = MagicMock()
FalseValidator.validate = MagicMock(return_value=False)
@pytest.mark.requests_workflow
def test_update_fv(fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -81,6 +82,7 @@ def test_update_fv(fv_data):
assert updated_request.is_pending_ccpo_approval
@pytest.mark.requests_workflow
def test_update_fv_re_enter_pe_number(fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -96,6 +98,7 @@ def test_update_fv_re_enter_pe_number(fv_data):
assert updated_request.is_pending_ccpo_approval
@pytest.mark.requests_workflow
def test_update_fv_invalid_task_order_number(fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -113,6 +116,7 @@ def test_update_fv_invalid_task_order_number(fv_data):
update_fv.execute()
@pytest.mark.requests_workflow
def test_draft_without_pe_id(fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -127,6 +131,7 @@ def test_draft_without_pe_id(fv_data):
).execute()
@pytest.mark.requests_workflow
def test_update_fv_extended(fv_data, e_fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -138,6 +143,7 @@ def test_update_fv_extended(fv_data, e_fv_data):
assert update_fv.execute()
@pytest.mark.requests_workflow
def test_update_fv_extended_does_not_validate_task_order(fv_data, e_fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -149,6 +155,7 @@ def test_update_fv_extended_does_not_validate_task_order(fv_data, e_fv_data):
assert update_fv.execute()
@pytest.mark.requests_workflow
def test_update_fv_missing_extended_data(fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -165,6 +172,7 @@ def test_update_fv_missing_extended_data(fv_data):
update_fv.execute()
@pytest.mark.requests_workflow
def test_update_fv_submission(fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -174,6 +182,7 @@ def test_update_fv_submission(fv_data):
assert updated_request
@pytest.mark.requests_workflow
def test_save_empty_draft():
request = RequestFactory.create()
user = UserFactory.create()
@@ -184,6 +193,7 @@ def test_save_empty_draft():
assert save_draft.execute()
@pytest.mark.requests_workflow
def test_save_draft_with_ba_code():
request = RequestFactory.create()
user = UserFactory.create()
@@ -195,6 +205,7 @@ def test_save_draft_with_ba_code():
assert save_draft.execute()
@pytest.mark.requests_workflow
def test_save_draft_allows_invalid_data():
request = RequestFactory.create()
user = UserFactory.create()
@@ -214,6 +225,7 @@ def test_save_draft_allows_invalid_data():
).execute()
@pytest.mark.requests_workflow
def test_save_draft_and_then_submit():
request = RequestFactory.create()
user = UserFactory.create()
@@ -228,6 +240,7 @@ def test_save_draft_and_then_submit():
).execute()
@pytest.mark.requests_workflow
def test_updated_request_has_pdf(fv_data, e_fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -238,6 +251,7 @@ def test_updated_request_has_pdf(fv_data, e_fv_data):
assert updated_request.legacy_task_order.pdf
@pytest.mark.requests_workflow
def test_can_save_draft_with_just_pdf(e_fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -250,6 +264,7 @@ def test_can_save_draft_with_just_pdf(e_fv_data):
assert form.legacy_task_order.pdf
@pytest.mark.requests_workflow
def test_task_order_info_present_in_extended_form(fv_data, e_fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -265,6 +280,7 @@ def test_task_order_info_present_in_extended_form(fv_data, e_fv_data):
assert form.legacy_task_order.clin_0001.data
@pytest.mark.requests_workflow
def test_update_ignores_empty_values(fv_data, e_fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -274,6 +290,7 @@ def test_update_ignores_empty_values(fv_data, e_fv_data):
).execute()
@pytest.mark.requests_workflow
def test_can_save_draft_with_funding_type(fv_data, e_fv_data):
request = RequestFactory.create()
user = UserFactory.create()
@@ -288,6 +305,7 @@ def test_can_save_draft_with_funding_type(fv_data, e_fv_data):
assert updated_request.legacy_task_order.funding_type
@pytest.mark.requests_workflow
def test_update_fv_route(client, user_session, fv_data):
user = UserFactory.create()
request = RequestFactory.create(creator=user)
@@ -301,6 +319,7 @@ def test_update_fv_route(client, user_session, fv_data):
assert response.status_code == 200
@pytest.mark.requests_workflow
def test_save_fv_draft_route(client, user_session, fv_data):
user = UserFactory.create()
request = RequestFactory.create(creator=user)
@@ -314,6 +333,7 @@ def test_save_fv_draft_route(client, user_session, fv_data):
assert response.status_code == 200
@pytest.mark.requests_workflow
def test_get_fv_form_route(client, user_session, fv_data):
user = UserFactory.create()
request = RequestFactory.create(creator=user)
@@ -327,6 +347,7 @@ def test_get_fv_form_route(client, user_session, fv_data):
assert response.status_code == 200
@pytest.mark.requests_workflow
def test_manual_task_order_triggers_extended_form(
client, user_session, fv_data, e_fv_data
):
@@ -348,6 +369,7 @@ def test_manual_task_order_triggers_extended_form(
assert "extended" in response.headers["Location"]
@pytest.mark.requests_workflow
def test_manual_to_does_not_trigger_approval(client, user_session, fv_data, e_fv_data):
user = UserFactory.create()
request = RequestFactory.create(creator=user)
@@ -370,6 +392,7 @@ def test_manual_to_does_not_trigger_approval(client, user_session, fv_data, e_fv
assert updated_request.status != RequestStatus.APPROVED
@pytest.mark.requests_workflow
def test_eda_task_order_does_trigger_approval(client, user_session, fv_data, e_fv_data):
user = UserFactory.create()
request = RequestFactory.create(creator=user)
@@ -392,6 +415,7 @@ def test_eda_task_order_does_trigger_approval(client, user_session, fv_data, e_f
assert updated_request.status == RequestStatus.APPROVED
@pytest.mark.requests_workflow
def test_attachment_on_non_extended_form(client, user_session, fv_data, e_fv_data):
user = UserFactory.create()
request = RequestFactory.create(creator=user)
@@ -417,6 +441,7 @@ def test_attachment_on_non_extended_form(client, user_session, fv_data, e_fv_dat
assert response.status_code == 200
@pytest.mark.requests_workflow
def test_task_order_number_persists_in_form(fv_data, e_fv_data):
user = UserFactory.create()
request = RequestFactory.create(creator=user)
@@ -437,6 +462,7 @@ def test_task_order_number_persists_in_form(fv_data, e_fv_data):
assert form.legacy_task_order.number.data == MANUAL_TO_NUMBER
@pytest.mark.requests_workflow
def test_can_submit_once_to_details_are_entered(fv_data, e_fv_data):
user = UserFactory.create()
request = RequestFactory.create(creator=user)
@@ -464,6 +490,7 @@ def test_can_submit_once_to_details_are_entered(fv_data, e_fv_data):
).execute()
@pytest.mark.requests_workflow
def test_existing_task_order_with_pdf(fv_data, e_fv_data, client, user_session):
# Use finver route to create initial TO #1, complete with PDF
user = UserFactory.create()
@@ -496,6 +523,7 @@ def test_existing_task_order_with_pdf(fv_data, e_fv_data, client, user_session):
assert response.status_code == 200
@pytest.mark.requests_workflow
def test_pdf_clearing(fv_data, e_fv_data, pdf_upload, pdf_upload2):
user = UserFactory.create()
request = RequestFactory.create(creator=user)
@@ -521,6 +549,7 @@ def test_pdf_clearing(fv_data, e_fv_data, pdf_upload, pdf_upload2):
# in the related attachment entity. I have changed the handling in
# FinancialVerificationBase#_get_form to be more generous in how it finds the
# PDF filename and prepopulates the form data with that name.
@pytest.mark.requests_workflow
def test_always_derives_pdf_filename(fv_data, e_fv_data, pdf_upload):
user = UserFactory.create()
request_one = RequestFactory.create(creator=user)

View File

@@ -1,3 +1,4 @@
import pytest
from flask import url_for
from atst.routes.requests.index import RequestsIndex
@@ -5,6 +6,7 @@ from tests.factories import RequestFactory, UserFactory
from atst.domain.requests import Requests
@pytest.mark.requests_workflow
def test_action_required_mission_owner():
creator = UserFactory.create()
requests = RequestFactory.create_batch(5, creator=creator)
@@ -16,6 +18,7 @@ def test_action_required_mission_owner():
assert context["requests"][0]["action_required"] == False
@pytest.mark.requests_workflow
def test_action_required_ccpo():
creator = UserFactory.create()
requests = RequestFactory.create_batch(5, creator=creator)

View File

@@ -4,20 +4,22 @@ from urllib.parse import quote
from tests.factories import UserFactory
PROTECTED_URL = "/workspaces"
def test_request_page_with_complete_profile(client, user_session):
user = UserFactory.create()
user_session(user)
response = client.get("/requests", follow_redirects=False)
response = client.get(PROTECTED_URL, follow_redirects=False)
assert response.status_code == 200
def test_redirect_when_profile_missing_fields(client, user_session):
user = UserFactory.create(date_latest_training=None)
user_session(user)
requested_url = "/requests"
response = client.get(requested_url, follow_redirects=False)
response = client.get(PROTECTED_URL, follow_redirects=False)
assert response.status_code == 302
assert "/user?next={}".format(quote(requested_url, safe="")) in response.location
assert "/user?next={}".format(quote(PROTECTED_URL, safe="")) in response.location
def test_unprotected_route_with_incomplete_profile(client, user_session):
@@ -30,7 +32,7 @@ def test_unprotected_route_with_incomplete_profile(client, user_session):
def test_completing_user_profile(client, user_session):
user = UserFactory.create(phone_number=None)
user_session(user)
response = client.get("/requests", follow_redirects=True)
response = client.get(PROTECTED_URL, follow_redirects=True)
assert b"You must complete your profile" in response.data
updated_data = {**user.to_dictionary(), "phone_number": "5558675309"}
@@ -40,6 +42,6 @@ def test_completing_user_profile(client, user_session):
response = client.post(url_for("users.update_user"), data=updated_data)
assert response.status_code == 200
response = client.get("/requests", follow_redirects=False)
response = client.get(PROTECTED_URL, follow_redirects=False)
assert response.status_code == 200
assert b"You must complete your profile" not in response.data

View File

@@ -1,4 +1,5 @@
import pytest
from flask import url_for
@pytest.fixture
@@ -10,7 +11,7 @@ def csrf_enabled_app(app):
def test_csrf_error(csrf_enabled_app, client):
response = client.post(
"/requests/new/1",
url_for("users.user"),
headers={"Content-Type": "application/x-www-form-urlencoded"},
data="csrf_token=invalid_token",
follow_redirects=True,

View File

@@ -19,6 +19,7 @@ def test_user_without_workspaces_has_no_workspaces_nav(client, user_session):
assert b'href="/workspaces"' not in response.data
@pytest.mark.skip(reason="this may no longer be accurate")
def test_request_owner_with_no_workspaces_redirected_to_requests(client, user_session):
request = RequestFactory.create()
user_session(request.creator)
@@ -50,6 +51,7 @@ def test_request_owner_with_more_than_one_workspace_redirected_to_workspaces(
assert "/workspaces" in response.location
@pytest.mark.skip(reason="this may no longer be accurate")
def test_non_owner_user_with_no_workspaces_redirected_to_requests(client, user_session):
user = UserFactory.create()
@@ -86,6 +88,7 @@ def test_non_owner_user_with_mulitple_workspaces_redirected_to_workspaces(
assert "/workspaces" in response.location
@pytest.mark.skip(reason="this may no longer be accurate")
def test_ccpo_user_redirected_to_requests(client, user_session):
user = UserFactory.from_atat_role("ccpo")
for _ in range(3):