Fix setting default status on task orders
This commit is contained in:
parent
dda6db8562
commit
2b61621402
@ -33,7 +33,7 @@ class TaskOrder(Base, mixins.TimestampsMixin):
|
|||||||
so_id = Column(ForeignKey("users.id"))
|
so_id = Column(ForeignKey("users.id"))
|
||||||
security_officer = relationship("User", foreign_keys="TaskOrder.so_id")
|
security_officer = relationship("User", foreign_keys="TaskOrder.so_id")
|
||||||
|
|
||||||
status = Column(SQLAEnum(Status, native_enum=False, default=Status.PENDING))
|
status = Column(SQLAEnum(Status, native_enum=False))
|
||||||
|
|
||||||
scope = Column(String) # Cloud Project Scope
|
scope = Column(String) # Cloud Project Scope
|
||||||
defense_component = Column(String) # Department of Defense Component
|
defense_component = Column(String) # Department of Defense Component
|
||||||
@ -65,6 +65,11 @@ class TaskOrder(Base, mixins.TimestampsMixin):
|
|||||||
number = Column(String, unique=True) # Task Order Number
|
number = Column(String, unique=True) # Task Order Number
|
||||||
loa = Column(ARRAY(String)) # Line of Accounting (LOA)
|
loa = Column(ARRAY(String)) # Line of Accounting (LOA)
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
if "status" not in kwargs:
|
||||||
|
self.status = Status.PENDING
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def budget(self):
|
def budget(self):
|
||||||
return sum(
|
return sum(
|
||||||
|
20
tests/models/test_legacy_task_order.py
Normal file
20
tests/models/test_legacy_task_order.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
from tests.factories import LegacyTaskOrderFactory
|
||||||
|
from tests.assert_util import dict_contains
|
||||||
|
|
||||||
|
|
||||||
|
def test_as_dictionary():
|
||||||
|
data = LegacyTaskOrderFactory.dictionary()
|
||||||
|
real_task_order = LegacyTaskOrderFactory.create(**data)
|
||||||
|
assert dict_contains(real_task_order.to_dictionary(), data)
|
||||||
|
|
||||||
|
|
||||||
|
def test_budget():
|
||||||
|
legacy_task_order = LegacyTaskOrderFactory.create(
|
||||||
|
clin_0001=500,
|
||||||
|
clin_0003=200,
|
||||||
|
clin_1001=None,
|
||||||
|
clin_1003=None,
|
||||||
|
clin_2001=None,
|
||||||
|
clin_2003=None,
|
||||||
|
)
|
||||||
|
assert legacy_task_order.budget == 700
|
@ -1,20 +1,9 @@
|
|||||||
from tests.factories import LegacyTaskOrderFactory
|
from atst.models.task_order import TaskOrder, Status
|
||||||
from tests.assert_util import dict_contains
|
|
||||||
|
|
||||||
|
|
||||||
def test_as_dictionary():
|
def test_default_status():
|
||||||
data = LegacyTaskOrderFactory.dictionary()
|
to = TaskOrder()
|
||||||
real_task_order = LegacyTaskOrderFactory.create(**data)
|
assert to.status == Status.PENDING
|
||||||
assert dict_contains(real_task_order.to_dictionary(), data)
|
|
||||||
|
|
||||||
|
with_args = TaskOrder(number="42")
|
||||||
def test_budget():
|
assert to.status == Status.PENDING
|
||||||
legacy_task_order = LegacyTaskOrderFactory.create(
|
|
||||||
clin_0001=500,
|
|
||||||
clin_0003=200,
|
|
||||||
clin_1001=None,
|
|
||||||
clin_1003=None,
|
|
||||||
clin_2001=None,
|
|
||||||
clin_2003=None,
|
|
||||||
)
|
|
||||||
assert legacy_task_order.budget == 700
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user