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

@ -4,4 +4,3 @@ PGDATABASE = atat_test
REDIS_URI = redis://redishost:6379
CRL_DIRECTORY = tests/fixtures/crl
WTF_CSRF_ENABLED = false
REQUESTS_WORKFLOW=true

View File

@ -4,4 +4,3 @@ PGDATABASE = atat_test
CRL_DIRECTORY = tests/fixtures/crl
WTF_CSRF_ENABLED = false
STORAGE_PROVIDER=LOCAL
REQUESTS_WORKFLOW=true

View File

@ -15,7 +15,9 @@
JEDI Cloud provides commercial Infrastructure as a Service (IaaS) and Platform as a Service (PaaS) offerings to support DoD business and mission operations.<br>
<b>Anyone with a DoD mission may use JEDI</b>.
</p>
<a class="usa-button" href="{{ url_for('requests.requests_form_new', screen=1) }}"><span>New JEDI Request</span></a>
{% if config.get("REQUESTS_WORKFLOW") %}
<a class="usa-button" href="{{ url_for('requests.requests_form_new', screen=1) }}"><span>New JEDI Request</span></a>
{% endif %}
<h2>Five Steps to the JEDI Cloud</h2>
@ -27,7 +29,9 @@
<h3 class="h4">Complete a JEDI Cloud Access Request</h3>
<p>
A JEDI Cloud Access Request will inform the the Cloud Computing Program Office (CCPO) about your intention to use JEDI's commercial cloud services and provide the preliminary information needed to grant access.
Any DoD employee with a CAC may initiate this request. <a class="icon-link" href="{{ url_for('requests.requests_form_new', screen=1) }}">Start a Request</a>
{% if config.get("REQUESTS_WORKFLOW") %}
Any DoD employee with a CAC may initiate this request. <a class="icon-link" href="{{ url_for('requests.requests_form_new', screen=1) }}">Start a Request</a>
{% endif %}
</p>
</li>
<li>

View File

@ -147,3 +147,8 @@ def extended_financial_verification_data(pdf_upload):
def queue():
yield atst_queue
atst_queue.get_queue().empty()
pytest.mark.requests_workflow = pytest.mark.skipif(
not make_config().get("REQUESTS_WORKFLOW"), reason="requests workflow is deprecated"
)

View File

@ -21,6 +21,7 @@ def new_request(session):
return RequestFactory.create()
@pytest.mark.requests_workflow
def test_can_get_request():
factory_req = RequestFactory.create()
request = Requests.get(factory_req.creator, factory_req.id)
@ -28,17 +29,20 @@ def test_can_get_request():
assert request.id == factory_req.id
@pytest.mark.requests_workflow
def test_nonexistent_request_raises():
a_user = UserFactory.build()
with pytest.raises(NotFoundError):
Requests.get(a_user, uuid4())
@pytest.mark.requests_workflow
def test_new_request_has_started_status():
request = Requests.create(UserFactory.build(), {})
assert request.status == RequestStatus.STARTED
@pytest.mark.requests_workflow
def test_auto_approve_less_than_1m():
new_request = RequestFactory.create(initial_revision={"dollar_value": 999_999})
request = Requests.submit(new_request)
@ -48,6 +52,7 @@ def test_auto_approve_less_than_1m():
assert request.reviews[0].full_name_reviewer == "System"
@pytest.mark.requests_workflow
def test_dont_auto_approve_if_dollar_value_is_1m_or_above():
new_request = RequestFactory.create(initial_revision={"dollar_value": 1_000_000})
request = Requests.submit(new_request)
@ -55,6 +60,7 @@ def test_dont_auto_approve_if_dollar_value_is_1m_or_above():
assert request.status == RequestStatus.PENDING_CCPO_ACCEPTANCE
@pytest.mark.requests_workflow
def test_dont_auto_approve_if_no_dollar_value_specified():
new_request = RequestFactory.create(initial_revision={})
request = Requests.submit(new_request)
@ -62,6 +68,7 @@ def test_dont_auto_approve_if_no_dollar_value_specified():
assert request.status == RequestStatus.PENDING_CCPO_ACCEPTANCE
@pytest.mark.requests_workflow
def test_should_allow_submission():
new_request = RequestFactory.create()
@ -79,15 +86,18 @@ def test_should_allow_submission():
assert not Requests.should_allow_submission(new_request)
@pytest.mark.requests_workflow
def test_request_knows_its_last_submission_timestamp(new_request):
submitted_request = Requests.submit(new_request)
assert submitted_request.last_submission_timestamp
@pytest.mark.requests_workflow
def test_request_knows_if_it_has_no_last_submission_timestamp(new_request):
assert new_request.last_submission_timestamp is None
@pytest.mark.requests_workflow
def test_exists(session):
user_allowed = UserFactory.create()
user_denied = UserFactory.create()
@ -96,6 +106,7 @@ def test_exists(session):
assert not Requests.exists(request.id, user_denied)
@pytest.mark.requests_workflow
def test_status_count(session):
# make sure table is empty
session.query(Request).delete()
@ -114,6 +125,7 @@ def test_status_count(session):
assert Requests.in_progress_count() == 2
@pytest.mark.requests_workflow
def test_status_count_scoped_to_creator(session):
# make sure table is empty
session.query(Request).delete()
@ -143,12 +155,14 @@ request_financial_data = {
}
@pytest.mark.requests_workflow
def test_set_status_sets_revision():
request = RequestFactory.create()
Requests.set_status(request, RequestStatus.APPROVED)
assert request.latest_revision == request.status_events[-1].revision
@pytest.mark.requests_workflow
def test_advance_to_financial_verification():
request = RequestFactory.create_with_status(
status=RequestStatus.PENDING_CCPO_ACCEPTANCE
@ -160,6 +174,7 @@ def test_advance_to_financial_verification():
assert current_review.fname_mao == review_data["fname_mao"]
@pytest.mark.requests_workflow
def test_advance_to_approval():
request = RequestFactory.create_with_status(
status=RequestStatus.PENDING_CCPO_APPROVAL
@ -169,6 +184,7 @@ def test_advance_to_approval():
assert request.status == RequestStatus.APPROVED
@pytest.mark.requests_workflow
def test_request_changes_to_request_application():
request = RequestFactory.create_with_status(
status=RequestStatus.PENDING_CCPO_ACCEPTANCE
@ -180,6 +196,7 @@ def test_request_changes_to_request_application():
assert current_review.fname_mao == review_data["fname_mao"]
@pytest.mark.requests_workflow
def test_request_changes_to_financial_verification_info():
request = RequestFactory.create_with_status(
status=RequestStatus.PENDING_CCPO_APPROVAL
@ -191,6 +208,7 @@ def test_request_changes_to_financial_verification_info():
assert current_review.fname_mao == review_data["fname_mao"]
@pytest.mark.requests_workflow
def test_add_internal_comment():
request = RequestFactory.create()
ccpo = UserFactory.from_atat_role("ccpo")
@ -203,6 +221,7 @@ def test_add_internal_comment():
assert request.internal_comments[0].text == "this is my comment"
@pytest.mark.requests_workflow
def test_creator_can_view_own_request():
creator = UserFactory.create()
request = RequestFactory.create(creator=creator)
@ -210,6 +229,7 @@ def test_creator_can_view_own_request():
assert RequestsAuthorization(creator, request).can_view
@pytest.mark.requests_workflow
def test_ccpo_can_view_request():
ccpo = UserFactory.from_atat_role("ccpo")
request = RequestFactory.create()
@ -217,6 +237,7 @@ def test_ccpo_can_view_request():
assert RequestsAuthorization(ccpo, request).can_view
@pytest.mark.requests_workflow
def test_random_user_cannot_view_request():
user = UserFactory.create()
request = RequestFactory.create()
@ -224,6 +245,7 @@ def test_random_user_cannot_view_request():
assert not RequestsAuthorization(user, request).can_view
@pytest.mark.requests_workflow
def test_auto_approve_and_create_workspace():
request = RequestFactory.create()
workspace = Requests.auto_approve_and_create_workspace(request)
@ -239,6 +261,7 @@ class TestStatusNotifications(object):
assert job.func == queue._send_mail
assert job.args[0] == [request.creator.email]
@pytest.mark.requests_workflow
def test_pending_finver_triggers_notification(self, queue):
request = RequestFactory.create()
request = Requests.set_status(request, RequestStatus.PENDING_CCPO_ACCEPTANCE)
@ -247,12 +270,14 @@ class TestStatusNotifications(object):
)
self._assert_job(queue, request)
@pytest.mark.requests_workflow
def test_changes_requested_triggers_notification(self, queue):
request = RequestFactory.create()
request = Requests.set_status(request, RequestStatus.PENDING_CCPO_ACCEPTANCE)
request = Requests.set_status(request, RequestStatus.CHANGES_REQUESTED)
self._assert_job(queue, request)
@pytest.mark.requests_workflow
def test_changes_requested_to_finver_triggers_notification(self, queue):
request = RequestFactory.create()
request = Requests.set_status(request, RequestStatus.PENDING_CCPO_APPROVAL)
@ -261,12 +286,14 @@ class TestStatusNotifications(object):
)
self._assert_job(queue, request)
@pytest.mark.requests_workflow
def test_approval_triggers_notification(self, queue):
request = RequestFactory.create()
request = Requests.set_status(request, RequestStatus.PENDING_CCPO_APPROVAL)
request = Requests.set_status(request, RequestStatus.APPROVED)
self._assert_job(queue, request)
@pytest.mark.requests_workflow
def test_submitted_does_not_trigger_notification(self, queue):
request = RequestFactory.create()
request = Requests.set_status(request, RequestStatus.SUBMITTED)

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):

View File

@ -189,11 +189,11 @@ def test_logout(app, client, monkeypatch):
)
# create a real session
resp = _login(client)
resp_success = client.get(url_for("requests.requests_index"))
resp_success = client.get(url_for("users.user"))
# verify session is valid
assert resp_success.status_code == 200
client.get(url_for("atst.logout"))
resp_failure = client.get(url_for("requests.requests_index"))
resp_failure = client.get(url_for("users.user"))
# verify that logging out has cleared the session
assert resp_failure.status_code == 302
destination = urlparse(resp_failure.headers["Location"]).path
@ -208,6 +208,6 @@ def test_redirected_on_login(client, monkeypatch):
"atst.domain.authnid.AuthenticationContext.get_user",
lambda *args: UserFactory.create(),
)
target_route = url_for("requests.requests_form_new", screen=1)
target_route = url_for("users.user")
response = _login(client, next=target_route)
assert target_route in response.headers.get("Location")

View File

@ -26,6 +26,7 @@ def serialize_dates(data):
return new_data
@pytest.mark.requests_workflow
def test_stepthrough_request_form(user_session, screens, client):
user = UserFactory.create()
user_session(user)

View File

@ -1,19 +0,0 @@
import pytest
@pytest.mark.parametrize(
"path",
(
"/workspaces",
"/requests",
"/requests/new/1",
"/users",
"/reports",
"/calculator",
),
)
def test_routes(path, client, user_session):
user_session()
response = client.get(path)
assert response.status_code == 200