Format project
This commit is contained in:
@@ -11,7 +11,7 @@ from tests.factories import UserFactory
|
||||
CERT = open("tests/fixtures/{}.crt".format(FIXTURE_EMAIL_ADDRESS)).read()
|
||||
|
||||
|
||||
class MockCRLCache():
|
||||
class MockCRLCache:
|
||||
def __init__(self, valid=True):
|
||||
self.valid = valid
|
||||
|
||||
@@ -23,16 +23,12 @@ class MockCRLCache():
|
||||
|
||||
|
||||
def test_can_authenticate():
|
||||
auth_context = AuthenticationContext(
|
||||
MockCRLCache(), "SUCCESS", DOD_SDN, CERT
|
||||
)
|
||||
auth_context = AuthenticationContext(MockCRLCache(), "SUCCESS", DOD_SDN, CERT)
|
||||
assert auth_context.authenticate()
|
||||
|
||||
|
||||
def test_unsuccessful_status():
|
||||
auth_context = AuthenticationContext(
|
||||
MockCRLCache(), "FAILURE", DOD_SDN, CERT
|
||||
)
|
||||
auth_context = AuthenticationContext(MockCRLCache(), "FAILURE", DOD_SDN, CERT)
|
||||
with pytest.raises(UnauthenticatedError) as excinfo:
|
||||
assert auth_context.authenticate()
|
||||
|
||||
@@ -41,9 +37,7 @@ def test_unsuccessful_status():
|
||||
|
||||
|
||||
def test_crl_check_fails():
|
||||
auth_context = AuthenticationContext(
|
||||
MockCRLCache(False), "SUCCESS", DOD_SDN, CERT
|
||||
)
|
||||
auth_context = AuthenticationContext(MockCRLCache(False), "SUCCESS", DOD_SDN, CERT)
|
||||
with pytest.raises(UnauthenticatedError) as excinfo:
|
||||
assert auth_context.authenticate()
|
||||
|
||||
@@ -52,9 +46,7 @@ def test_crl_check_fails():
|
||||
|
||||
|
||||
def test_bad_sdn():
|
||||
auth_context = AuthenticationContext(
|
||||
MockCRLCache(), "SUCCESS", "abc123", CERT
|
||||
)
|
||||
auth_context = AuthenticationContext(MockCRLCache(), "SUCCESS", "abc123", CERT)
|
||||
with pytest.raises(UnauthenticatedError) as excinfo:
|
||||
auth_context.get_user()
|
||||
|
||||
@@ -64,9 +56,7 @@ def test_bad_sdn():
|
||||
|
||||
def test_user_exists():
|
||||
user = UserFactory.create(**DOD_SDN_INFO)
|
||||
auth_context = AuthenticationContext(
|
||||
MockCRLCache(), "SUCCESS", DOD_SDN, CERT
|
||||
)
|
||||
auth_context = AuthenticationContext(MockCRLCache(), "SUCCESS", DOD_SDN, CERT)
|
||||
auth_user = auth_context.get_user()
|
||||
|
||||
assert auth_user == user
|
||||
@@ -77,9 +67,7 @@ def test_creates_user():
|
||||
with pytest.raises(NotFoundError):
|
||||
Users.get_by_dod_id(DOD_SDN_INFO["dod_id"])
|
||||
|
||||
auth_context = AuthenticationContext(
|
||||
MockCRLCache(), "SUCCESS", DOD_SDN, CERT
|
||||
)
|
||||
auth_context = AuthenticationContext(MockCRLCache(), "SUCCESS", DOD_SDN, CERT)
|
||||
user = auth_context.get_user()
|
||||
assert user.dod_id == DOD_SDN_INFO["dod_id"]
|
||||
assert user.email == FIXTURE_EMAIL_ADDRESS
|
||||
@@ -87,9 +75,7 @@ def test_creates_user():
|
||||
|
||||
def test_user_cert_has_no_email():
|
||||
cert = open("ssl/client-certs/atat.mil.crt").read()
|
||||
auth_context = AuthenticationContext(
|
||||
MockCRLCache(), "SUCCESS", DOD_SDN, cert
|
||||
)
|
||||
auth_context = AuthenticationContext(MockCRLCache(), "SUCCESS", DOD_SDN, cert)
|
||||
user = auth_context.get_user()
|
||||
|
||||
assert user.email == None
|
||||
|
@@ -11,8 +11,7 @@ import atst.domain.authnid.crl.util as util
|
||||
from tests.mocks import FIXTURE_EMAIL_ADDRESS
|
||||
|
||||
|
||||
class MockX509Store():
|
||||
|
||||
class MockX509Store:
|
||||
def __init__(self):
|
||||
self.crls = []
|
||||
self.certs = []
|
||||
@@ -98,8 +97,7 @@ def test_parse_disa_pki_list():
|
||||
assert len(crl_list) == len(href_matches)
|
||||
|
||||
|
||||
class MockStreamingResponse():
|
||||
|
||||
class MockStreamingResponse:
|
||||
def __init__(self, content_chunks, code=200):
|
||||
self.content_chunks = content_chunks
|
||||
self.status_code = code
|
||||
|
@@ -18,4 +18,3 @@ def test_invalid_date():
|
||||
date_str = "This is not a valid data"
|
||||
with pytest.raises(ValueError):
|
||||
parse_date(date_str)
|
||||
|
||||
|
@@ -7,7 +7,9 @@ from tests.factories import PENumberFactory
|
||||
|
||||
|
||||
def test_can_get_pe_number():
|
||||
new_pen = PENumberFactory.create(number="0701367F", description="Combat Support - Offensive")
|
||||
new_pen = PENumberFactory.create(
|
||||
number="0701367F", description="Combat Support - Offensive"
|
||||
)
|
||||
pen = PENumbers.get(new_pen.number)
|
||||
|
||||
assert pen.number == new_pen.number
|
||||
@@ -17,8 +19,9 @@ def test_nonexistent_pe_number_raises():
|
||||
with pytest.raises(NotFoundError):
|
||||
PENumbers.get("some fake number")
|
||||
|
||||
|
||||
def test_create_many():
|
||||
pen_list = [['123456', 'Land Speeder'], ['7891011', 'Lightsaber']]
|
||||
pen_list = [["123456", "Land Speeder"], ["7891011", "Lightsaber"]]
|
||||
PENumbers.create_many(pen_list)
|
||||
|
||||
assert PENumbers.get(pen_list[0][0])
|
||||
|
@@ -7,7 +7,12 @@ from atst.models.request import Request
|
||||
from atst.models.request_status_event import RequestStatus
|
||||
from atst.models.task_order import Source as TaskOrderSource
|
||||
|
||||
from tests.factories import RequestFactory, UserFactory, RequestStatusEventFactory, TaskOrderFactory
|
||||
from tests.factories import (
|
||||
RequestFactory,
|
||||
UserFactory,
|
||||
RequestStatusEventFactory,
|
||||
TaskOrderFactory,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
@@ -55,10 +60,12 @@ def test_dont_auto_approve_if_no_dollar_value_specified(new_request):
|
||||
def test_should_allow_submission(new_request):
|
||||
assert Requests.should_allow_submission(new_request)
|
||||
|
||||
RequestStatusEventFactory.create(request=new_request, new_status=RequestStatus.CHANGES_REQUESTED)
|
||||
RequestStatusEventFactory.create(
|
||||
request=new_request, new_status=RequestStatus.CHANGES_REQUESTED
|
||||
)
|
||||
assert Requests.should_allow_submission(new_request)
|
||||
|
||||
del new_request.body['details_of_use']
|
||||
del new_request.body["details_of_use"]
|
||||
assert not Requests.should_allow_submission(new_request)
|
||||
|
||||
|
||||
@@ -76,12 +83,17 @@ def test_status_count(session):
|
||||
|
||||
request1 = RequestFactory.create()
|
||||
request2 = RequestFactory.create()
|
||||
RequestStatusEventFactory.create(sequence=2, request_id=request2.id, new_status=RequestStatus.PENDING_FINANCIAL_VERIFICATION)
|
||||
RequestStatusEventFactory.create(
|
||||
sequence=2,
|
||||
request_id=request2.id,
|
||||
new_status=RequestStatus.PENDING_FINANCIAL_VERIFICATION,
|
||||
)
|
||||
|
||||
assert Requests.status_count(RequestStatus.PENDING_FINANCIAL_VERIFICATION) == 1
|
||||
assert Requests.status_count(RequestStatus.STARTED) == 1
|
||||
assert Requests.in_progress_count() == 2
|
||||
|
||||
|
||||
def test_status_count_scoped_to_creator(session):
|
||||
# make sure table is empty
|
||||
session.query(Request).delete()
|
||||
@@ -123,7 +135,7 @@ task_order_financial_data = {
|
||||
|
||||
def test_update_financial_verification_without_task_order():
|
||||
request = RequestFactory.create()
|
||||
financial_data = { **request_financial_data, **task_order_financial_data }
|
||||
financial_data = {**request_financial_data, **task_order_financial_data}
|
||||
Requests.update_financial_verification(request.id, financial_data)
|
||||
assert request.task_order
|
||||
assert request.task_order.clin_0001 == task_order_financial_data["clin_0001"]
|
||||
@@ -132,7 +144,7 @@ def test_update_financial_verification_without_task_order():
|
||||
|
||||
def test_update_financial_verification_with_task_order():
|
||||
task_order = TaskOrderFactory.create(source=TaskOrderSource.EDA)
|
||||
financial_data = { **request_financial_data, "task_order_number": task_order.number }
|
||||
financial_data = {**request_financial_data, "task_order_number": task_order.number}
|
||||
request = RequestFactory.create()
|
||||
Requests.update_financial_verification(request.id, financial_data)
|
||||
assert request.task_order == task_order
|
||||
@@ -142,4 +154,3 @@ def test_update_financial_verification_with_invalid_task_order():
|
||||
request = RequestFactory.create()
|
||||
Requests.update_financial_verification(request.id, request_financial_data)
|
||||
assert not request.task_order
|
||||
|
||||
|
@@ -16,7 +16,9 @@ def test_can_get_task_order():
|
||||
|
||||
|
||||
def test_can_get_task_order_from_eda(monkeypatch):
|
||||
monkeypatch.setattr("atst.domain.task_orders.TaskOrders._client", lambda: MockEDAClient())
|
||||
monkeypatch.setattr(
|
||||
"atst.domain.task_orders.TaskOrders._client", lambda: MockEDAClient()
|
||||
)
|
||||
to = TaskOrders.get(MockEDAClient.MOCK_CONTRACT_NUMBER)
|
||||
|
||||
assert to.number == MockEDAClient.MOCK_CONTRACT_NUMBER
|
||||
@@ -29,6 +31,8 @@ def test_nonexistent_task_order_raises_without_client():
|
||||
|
||||
|
||||
def test_nonexistent_task_order_raises_with_client(monkeypatch):
|
||||
monkeypatch.setattr("atst.domain.task_orders.TaskOrders._client", lambda: MockEDAClient())
|
||||
monkeypatch.setattr(
|
||||
"atst.domain.task_orders.TaskOrders._client", lambda: MockEDAClient()
|
||||
)
|
||||
with pytest.raises(NotFoundError):
|
||||
TaskOrders.get("some other fake numer")
|
||||
|
Reference in New Issue
Block a user