From ebac93bc23af85e6c54c8a557db95829a3331fcd Mon Sep 17 00:00:00 2001 From: dandds Date: Mon, 10 Sep 2018 11:22:59 -0400 Subject: [PATCH] run reformatter --- atst/domain/requests.py | 26 +++++++++++++++----------- atst/forms/ccpo_review.py | 7 ++----- atst/routes/requests/approval.py | 9 ++++++++- atst/routes/requests/index.py | 4 +++- tests/domain/test_requests.py | 1 - tests/factories.py | 4 +++- tests/routes/test_request_approval.py | 5 ++++- tests/routes/test_requests_index.py | 10 ++++------ 8 files changed, 39 insertions(+), 27 deletions(-) diff --git a/atst/domain/requests.py b/atst/domain/requests.py index 3eb3617f..5c853630 100644 --- a/atst/domain/requests.py +++ b/atst/domain/requests.py @@ -76,9 +76,10 @@ class Requests(object): filters.append(Request.creator == creator) requests = ( - db.session.query(Request).filter(*filters).order_by( - Request.time_created.desc() - ).all() + db.session.query(Request) + .filter(*filters) + .order_by(Request.time_created.desc()) + .all() ) return requests @@ -118,9 +119,10 @@ class Requests(object): # Query for request matching id, acquiring a row-level write lock. # https://www.postgresql.org/docs/10/static/sql-select.html#SQL-FOR-UPDATE-SHARE return ( - db.session.query(Request).filter_by(id=request_id).with_for_update( - of=Request - ).one() + db.session.query(Request) + .filter_by(id=request_id) + .with_for_update(of=Request) + .one() ) except NoResultFound: @@ -154,13 +156,16 @@ class Requests(object): return dollar_value < cls.AUTO_APPROVE_THRESHOLD _VALID_SUBMISSION_STATUSES = [ - RequestStatus.STARTED, RequestStatus.CHANGES_REQUESTED + RequestStatus.STARTED, + RequestStatus.CHANGES_REQUESTED, ] @classmethod def should_allow_submission(cls, request): all_request_sections = [ - "details_of_use", "information_about_you", "primary_poc" + "details_of_use", + "information_about_you", + "primary_poc", ] existing_request_sections = request.body.keys() return request.status in Requests._VALID_SUBMISSION_STATUSES and all( @@ -241,9 +246,8 @@ WHERE requests_with_status.status = :status else: task_order_number = request_data.get("task_order_number") - if ( - "task_order" in request_data - and isinstance(request_data["task_order"], FileStorage) + if "task_order" in request_data and isinstance( + request_data["task_order"], FileStorage ): task_order_data["pdf"] = request_data.pop("task_order") diff --git a/atst/forms/ccpo_review.py b/atst/forms/ccpo_review.py index 89b5ed03..b1809ad6 100644 --- a/atst/forms/ccpo_review.py +++ b/atst/forms/ccpo_review.py @@ -7,15 +7,12 @@ from .validators import Alphabet, PhoneNumber class CCPOReviewForm(ValidatedForm): - comments = TextAreaField( - "Comments (optional)", - ) + comments = TextAreaField("Comments (optional)") fname_mao = StringField("First Name", validators=[Required(), Alphabet()]) lname_mao = StringField("Last Name", validators=[Required(), Alphabet()]) email_mao = EmailField("Mission Owner e-mail (optional)", validators=[Email()]) phone_mao = TelField( - "Mission Owner phone number (optional)", - validators=[PhoneNumber()], + "Mission Owner phone number (optional)", validators=[PhoneNumber()] ) fname_ccpo = StringField("First Name", validators=[Required(), Alphabet()]) lname_ccpo = StringField("Last Name", validators=[Required(), Alphabet()]) diff --git a/atst/routes/requests/approval.py b/atst/routes/requests/approval.py index b78b0375..66be2233 100644 --- a/atst/routes/requests/approval.py +++ b/atst/routes/requests/approval.py @@ -1,4 +1,11 @@ -from flask import render_template, g, Response, request as http_request, redirect, url_for +from flask import ( + render_template, + g, + Response, + request as http_request, + redirect, + url_for, +) from flask import current_app as app from . import requests_bp diff --git a/atst/routes/requests/index.py b/atst/routes/requests/index.py index 7032c12f..8553c0d6 100644 --- a/atst/routes/requests/index.py +++ b/atst/routes/requests/index.py @@ -76,7 +76,9 @@ class RequestsIndex(object): edit_link = url_for( "requests.financial_verification", request_id=request.id ) - elif Requests.is_pending_ccpo_acceptance(request) or Requests.is_pending_ccpo_approval(request): + elif Requests.is_pending_ccpo_acceptance( + request + ) or Requests.is_pending_ccpo_approval(request): edit_link = url_for("requests.view_pending_request", request_id=request.id) else: edit_link = url_for( diff --git a/tests/domain/test_requests.py b/tests/domain/test_requests.py index 50227ba1..78a66389 100644 --- a/tests/domain/test_requests.py +++ b/tests/domain/test_requests.py @@ -188,4 +188,3 @@ def test_accept_for_financial_verification(): assert request.status == RequestStatus.PENDING_FINANCIAL_VERIFICATION current_review = request.latest_status.review assert current_review.fname_mao == review_data["fname_mao"] - diff --git a/tests/factories.py b/tests/factories.py index fa1036c9..58c2861c 100644 --- a/tests/factories.py +++ b/tests/factories.py @@ -70,7 +70,9 @@ class RequestReviewFactory(Base): fname_mao = factory.Faker("first_name") lname_mao = factory.Faker("last_name") email_mao = factory.Faker("email") - phone_mao = factory.LazyFunction(lambda: "".join(random.choices(string.digits, k=10))) + phone_mao = factory.LazyFunction( + lambda: "".join(random.choices(string.digits, k=10)) + ) fname_ccpo = factory.Faker("first_name") lname_ccpo = factory.Faker("last_name") diff --git a/tests/routes/test_request_approval.py b/tests/routes/test_request_approval.py index 3a0a05c2..ced46240 100644 --- a/tests/routes/test_request_approval.py +++ b/tests/routes/test_request_approval.py @@ -6,7 +6,10 @@ from atst.models.request_status_event import RequestStatus from atst.domain.roles import Roles from tests.factories import ( - RequestFactory, TaskOrderFactory, UserFactory, RequestReviewFactory + RequestFactory, + TaskOrderFactory, + UserFactory, + RequestReviewFactory, ) diff --git a/tests/routes/test_requests_index.py b/tests/routes/test_requests_index.py index c8d6fa5d..29300b65 100644 --- a/tests/routes/test_requests_index.py +++ b/tests/routes/test_requests_index.py @@ -30,13 +30,11 @@ def test_ccpo_sees_approval_screen(): request = RequestFactory.create() Requests.submit(request) ccpo_context = RequestsIndex(ccpo).execute() - assert ( - ccpo_context["requests"][0]["edit_link"] - == url_for("requests.approval", request_id=request.id) + assert ccpo_context["requests"][0]["edit_link"] == url_for( + "requests.approval", request_id=request.id ) mo_context = RequestsIndex(request.creator).execute() - assert ( - mo_context["requests"][0]["edit_link"] - != url_for("requests.approval", request_id=request.id) + assert mo_context["requests"][0]["edit_link"] != url_for( + "requests.approval", request_id=request.id )