Merge pull request #243 from dod-ccpo/action-required-flag
Action required flag
This commit is contained in:
@@ -11,7 +11,6 @@ from atst.models.task_order import TaskOrder
|
||||
from atst.models.user import User
|
||||
from atst.models.role import Role
|
||||
from atst.models.workspace import Workspace
|
||||
from atst.models.request_status_event import RequestStatusEvent
|
||||
from atst.domain.roles import Roles
|
||||
|
||||
|
||||
@@ -33,6 +32,11 @@ class UserFactory(factory.alchemy.SQLAlchemyModelFactory):
|
||||
atat_role = factory.SubFactory(RoleFactory)
|
||||
dod_id = factory.LazyFunction(lambda: "".join(random.choices(string.digits, k=10)))
|
||||
|
||||
@classmethod
|
||||
def from_atat_role(cls, atat_role_name, **kwargs):
|
||||
role = Roles.get(atat_role_name)
|
||||
return cls.create(atat_role=role, **kwargs)
|
||||
|
||||
|
||||
class RequestStatusEventFactory(factory.alchemy.SQLAlchemyModelFactory):
|
||||
class Meta:
|
||||
|
@@ -2,23 +2,18 @@ from tests.factories import RequestFactory, UserFactory
|
||||
from atst.domain.requests import Requests, RequestStatus
|
||||
|
||||
|
||||
def test_started_request_requires_mo_action():
|
||||
request = RequestFactory.create()
|
||||
assert Requests.action_required_by(request) == "mission_owner"
|
||||
|
||||
|
||||
def test_pending_financial_requires_mo_action():
|
||||
request = RequestFactory.create()
|
||||
request = Requests.set_status(request, RequestStatus.PENDING_FINANCIAL_VERIFICATION)
|
||||
|
||||
assert Requests.action_required_by(request) == "mission_owner"
|
||||
assert request.action_required_by == "mission_owner"
|
||||
|
||||
|
||||
def test_pending_ccpo_approval_requires_ccpo():
|
||||
request = RequestFactory.create()
|
||||
request = Requests.set_status(request, RequestStatus.PENDING_CCPO_APPROVAL)
|
||||
|
||||
assert Requests.action_required_by(request) == "ccpo"
|
||||
assert request.action_required_by == "ccpo"
|
||||
|
||||
|
||||
def test_request_has_creator():
|
||||
|
23
tests/routes/test_requests_index.py
Normal file
23
tests/routes/test_requests_index.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from atst.routes.requests.index import RequestsIndex
|
||||
from tests.factories import RequestFactory, UserFactory
|
||||
from atst.domain.requests import Requests
|
||||
|
||||
|
||||
def test_action_required_mission_owner():
|
||||
creator = UserFactory.create()
|
||||
requests = RequestFactory.create_batch(5, creator=creator)
|
||||
Requests.submit(requests[0])
|
||||
context = RequestsIndex(creator).execute()
|
||||
|
||||
assert context["requests"][0]["action_required"] == False
|
||||
|
||||
|
||||
def test_action_required_ccpo():
|
||||
creator = UserFactory.create()
|
||||
requests = RequestFactory.create_batch(5, creator=creator)
|
||||
Requests.submit(requests[0])
|
||||
|
||||
ccpo = UserFactory.from_atat_role("ccpo")
|
||||
context = RequestsIndex(ccpo).execute()
|
||||
|
||||
assert context["num_action_required"] == 1
|
Reference in New Issue
Block a user