remove fundz_client in favor of pe numbers repo
This commit is contained in:
parent
fc535ea715
commit
cb30ee99ca
@ -65,7 +65,6 @@ def make_app(config, deps, **kwargs):
|
|||||||
{
|
{
|
||||||
"page": "requests_new",
|
"page": "requests_new",
|
||||||
"db_session": deps["db_session"],
|
"db_session": deps["db_session"],
|
||||||
"fundz_client": deps["fundz_client"],
|
|
||||||
},
|
},
|
||||||
name="request_new",
|
name="request_new",
|
||||||
),
|
),
|
||||||
@ -75,7 +74,6 @@ def make_app(config, deps, **kwargs):
|
|||||||
{
|
{
|
||||||
"page": "requests_new",
|
"page": "requests_new",
|
||||||
"db_session": deps["db_session"],
|
"db_session": deps["db_session"],
|
||||||
"fundz_client": deps["fundz_client"],
|
|
||||||
},
|
},
|
||||||
name="request_form_new",
|
name="request_form_new",
|
||||||
),
|
),
|
||||||
@ -85,7 +83,6 @@ def make_app(config, deps, **kwargs):
|
|||||||
{
|
{
|
||||||
"page": "requests_new",
|
"page": "requests_new",
|
||||||
"db_session": deps["db_session"],
|
"db_session": deps["db_session"],
|
||||||
"fundz_client": deps["fundz_client"],
|
|
||||||
},
|
},
|
||||||
name="request_form_update",
|
name="request_form_update",
|
||||||
),
|
),
|
||||||
@ -108,7 +105,6 @@ def make_app(config, deps, **kwargs):
|
|||||||
{
|
{
|
||||||
"page": "financial_verification",
|
"page": "financial_verification",
|
||||||
"db_session": deps["db_session"],
|
"db_session": deps["db_session"],
|
||||||
"fundz_client": deps["fundz_client"],
|
|
||||||
},
|
},
|
||||||
name="financial_verification",
|
name="financial_verification",
|
||||||
),
|
),
|
||||||
@ -172,9 +168,6 @@ def make_deps(config):
|
|||||||
api_version="v1",
|
api_version="v1",
|
||||||
validate_cert=validate_cert,
|
validate_cert=validate_cert,
|
||||||
),
|
),
|
||||||
"fundz_client": ApiClient(
|
|
||||||
config["default"]["FUNDZ_BASE_URL"], validate_cert=validate_cert
|
|
||||||
),
|
|
||||||
"sessions": RedisSessions(
|
"sessions": RedisSessions(
|
||||||
redis_client, config["default"]["SESSION_TTL_SECONDS"]
|
redis_client, config["default"]["SESSION_TTL_SECONDS"]
|
||||||
),
|
),
|
||||||
|
@ -6,6 +6,8 @@ from wtforms.fields import StringField, SelectField
|
|||||||
from wtforms.form import Form
|
from wtforms.form import Form
|
||||||
from wtforms.validators import Required, Email
|
from wtforms.validators import Required, Email
|
||||||
|
|
||||||
|
from atst.domain.exceptions import NotFoundError
|
||||||
|
|
||||||
from .fields import NewlineListField
|
from .fields import NewlineListField
|
||||||
from .forms import ValidatedForm
|
from .forms import ValidatedForm
|
||||||
|
|
||||||
@ -35,12 +37,10 @@ def suggest_pe_id(pe_id):
|
|||||||
|
|
||||||
|
|
||||||
@tornado.gen.coroutine
|
@tornado.gen.coroutine
|
||||||
def validate_pe_id(field, existing_request, fundz_client):
|
def validate_pe_id(field, existing_request, pe_numbers_repo):
|
||||||
response = yield fundz_client.get(
|
try:
|
||||||
"/pe-number/{}".format(field.data),
|
pe_number = pe_numbers_repo.get(field.data)
|
||||||
raise_error=False,
|
except NotFoundError:
|
||||||
)
|
|
||||||
if not response.ok:
|
|
||||||
suggestion = suggest_pe_id(field.data)
|
suggestion = suggest_pe_id(field.data)
|
||||||
error_str = (
|
error_str = (
|
||||||
"We couldn't find that PE number. {}"
|
"We couldn't find that PE number. {}"
|
||||||
@ -56,10 +56,10 @@ def validate_pe_id(field, existing_request, fundz_client):
|
|||||||
class FinancialForm(ValidatedForm):
|
class FinancialForm(ValidatedForm):
|
||||||
|
|
||||||
@tornado.gen.coroutine
|
@tornado.gen.coroutine
|
||||||
def perform_extra_validation(self, existing_request, fundz_client):
|
def perform_extra_validation(self, existing_request, pe_numbers_repo):
|
||||||
valid = True
|
valid = True
|
||||||
if not existing_request or existing_request.get('pe_id') != self.pe_id.data:
|
if not existing_request or existing_request.get('pe_id') != self.pe_id.data:
|
||||||
valid = yield validate_pe_id(self.pe_id, existing_request, fundz_client)
|
valid = yield validate_pe_id(self.pe_id, existing_request, pe_numbers_repo)
|
||||||
raise Return(valid)
|
raise Return(valid)
|
||||||
|
|
||||||
task_order_id = StringField(
|
task_order_id = StringField(
|
||||||
|
@ -3,13 +3,14 @@ import tornado
|
|||||||
from atst.handler import BaseHandler
|
from atst.handler import BaseHandler
|
||||||
from atst.forms.financial import FinancialForm
|
from atst.forms.financial import FinancialForm
|
||||||
from atst.domain.requests import Requests
|
from atst.domain.requests import Requests
|
||||||
|
from atst.domain.pe_numbers import PENumbers
|
||||||
|
|
||||||
|
|
||||||
class RequestFinancialVerification(BaseHandler):
|
class RequestFinancialVerification(BaseHandler):
|
||||||
def initialize(self, page, db_session, fundz_client):
|
def initialize(self, page, db_session):
|
||||||
self.page = page
|
self.page = page
|
||||||
self.requests_repo = Requests(db_session)
|
self.requests_repo = Requests(db_session)
|
||||||
self.fundz_client = fundz_client
|
self.pe_numbers_repo = PENumbers(db_session)
|
||||||
|
|
||||||
def get_existing_request(self, request_id):
|
def get_existing_request(self, request_id):
|
||||||
return self.requests_repo.get(request_id)
|
return self.requests_repo.get(request_id)
|
||||||
@ -48,7 +49,7 @@ class RequestFinancialVerification(BaseHandler):
|
|||||||
yield self.update_request(request_id, form.data)
|
yield self.update_request(request_id, form.data)
|
||||||
valid = yield form.perform_extra_validation(
|
valid = yield form.perform_extra_validation(
|
||||||
existing_request.body.get('financial_verification'),
|
existing_request.body.get('financial_verification'),
|
||||||
self.fundz_client
|
self.pe_numbers_repo
|
||||||
)
|
)
|
||||||
if valid:
|
if valid:
|
||||||
self.redirect(
|
self.redirect(
|
||||||
|
@ -7,13 +7,14 @@ from atst.forms.org import OrgForm
|
|||||||
from atst.forms.poc import POCForm
|
from atst.forms.poc import POCForm
|
||||||
from atst.forms.review import ReviewForm
|
from atst.forms.review import ReviewForm
|
||||||
from atst.domain.requests import Requests
|
from atst.domain.requests import Requests
|
||||||
|
from atst.domain.pe_numbers import PENumbers
|
||||||
|
|
||||||
|
|
||||||
class RequestNew(BaseHandler):
|
class RequestNew(BaseHandler):
|
||||||
def initialize(self, page, db_session, fundz_client):
|
def initialize(self, page, db_session):
|
||||||
self.page = page
|
self.page = page
|
||||||
self.requests_repo = Requests(db_session)
|
self.requests_repo = Requests(db_session)
|
||||||
self.fundz_client = fundz_client
|
self.pe_numbers_repo = PENumbers(db_session)
|
||||||
|
|
||||||
def get_existing_request(self, request_id):
|
def get_existing_request(self, request_id):
|
||||||
if request_id is None:
|
if request_id is None:
|
||||||
@ -31,7 +32,7 @@ class RequestNew(BaseHandler):
|
|||||||
existing_request = self.get_existing_request(request_id)
|
existing_request = self.get_existing_request(request_id)
|
||||||
jedi_flow = JEDIRequestFlow(
|
jedi_flow = JEDIRequestFlow(
|
||||||
self.requests_repo,
|
self.requests_repo,
|
||||||
self.fundz_client,
|
self.pe_numbers_repo,
|
||||||
screen,
|
screen,
|
||||||
post_data=post_data,
|
post_data=post_data,
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
@ -81,7 +82,7 @@ class RequestNew(BaseHandler):
|
|||||||
request = self.requests_repo.get(request_id)
|
request = self.requests_repo.get(request_id)
|
||||||
|
|
||||||
jedi_flow = JEDIRequestFlow(
|
jedi_flow = JEDIRequestFlow(
|
||||||
self.requests_repo, self.fundz_client, screen, request, request_id=request_id
|
self.requests_repo, self.pe_numbers_repo, screen, request, request_id=request_id
|
||||||
)
|
)
|
||||||
|
|
||||||
self.render(
|
self.render(
|
||||||
@ -101,7 +102,7 @@ class JEDIRequestFlow(object):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
requests_repo,
|
requests_repo,
|
||||||
fundz_client,
|
pe_numbers_repo,
|
||||||
current_step,
|
current_step,
|
||||||
request=None,
|
request=None,
|
||||||
post_data=None,
|
post_data=None,
|
||||||
@ -110,7 +111,7 @@ class JEDIRequestFlow(object):
|
|||||||
existing_request=None,
|
existing_request=None,
|
||||||
):
|
):
|
||||||
self.requests_repo = requests_repo
|
self.requests_repo = requests_repo
|
||||||
self.fundz_client = fundz_client
|
self.pe_numbers_repo = pe_numbers_repo
|
||||||
|
|
||||||
self.current_step = current_step
|
self.current_step = current_step
|
||||||
self.request = request
|
self.request = request
|
||||||
@ -144,7 +145,7 @@ class JEDIRequestFlow(object):
|
|||||||
|
|
||||||
valid = yield self.form.perform_extra_validation(
|
valid = yield self.form.perform_extra_validation(
|
||||||
existing_request_data,
|
existing_request_data,
|
||||||
self.fundz_client,
|
self.pe_numbers_repo,
|
||||||
)
|
)
|
||||||
return valid
|
return valid
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ from atst.sessions import DictSessions
|
|||||||
def app(db):
|
def app(db):
|
||||||
TEST_DEPS = {
|
TEST_DEPS = {
|
||||||
"authnid_client": MockApiClient("authnid"),
|
"authnid_client": MockApiClient("authnid"),
|
||||||
"fundz_client": MockFundzClient("fundz"),
|
|
||||||
"sessions": DictSessions(),
|
"sessions": DictSessions(),
|
||||||
"db_session": db
|
"db_session": db
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@ import re
|
|||||||
import pytest
|
import pytest
|
||||||
import tornado
|
import tornado
|
||||||
import urllib
|
import urllib
|
||||||
from tests.mocks import MOCK_REQUEST, MOCK_USER, MOCK_VALID_PE_ID
|
from tests.mocks import MOCK_REQUEST, MOCK_USER
|
||||||
|
from tests.factories import PENumberFactory
|
||||||
|
|
||||||
|
|
||||||
class TestPENumberInForm:
|
class TestPENumberInForm:
|
||||||
@ -73,11 +74,14 @@ class TestPENumberInForm:
|
|||||||
assert response.headers.get("Location") == "/requests/financial_verification_submitted"
|
assert response.headers.get("Location") == "/requests/financial_verification_submitted"
|
||||||
|
|
||||||
@pytest.mark.gen_test
|
@pytest.mark.gen_test
|
||||||
def test_submit_request_form_with_new_valid_pe_id(self, monkeypatch, http_client, base_url):
|
def test_submit_request_form_with_new_valid_pe_id(self, db, monkeypatch, http_client, base_url):
|
||||||
self._set_monkeypatches(monkeypatch)
|
self._set_monkeypatches(monkeypatch)
|
||||||
|
pe = PENumberFactory.create(number="8675309U", description="sample PE number")
|
||||||
|
db.add(pe)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
data = dict(self.required_data)
|
data = dict(self.required_data)
|
||||||
data['pe_id'] = MOCK_VALID_PE_ID
|
data['pe_id'] = pe.number
|
||||||
|
|
||||||
response = yield self.submit_data(http_client, base_url, data)
|
response = yield self.submit_data(http_client, base_url, data)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user