Allow removing a csp estimate from a task order
This commit is contained in:
parent
c155de0e84
commit
672c562323
@ -86,6 +86,8 @@ class TaskOrder(Base, mixins.TimestampsMixin):
|
|||||||
self._csp_estimate = Attachment.attach(
|
self._csp_estimate = Attachment.attach(
|
||||||
new_csp_estimate, "task_order", self.id
|
new_csp_estimate, "task_order", self.id
|
||||||
)
|
)
|
||||||
|
elif not new_csp_estimate and self._csp_estimate:
|
||||||
|
self._csp_estimate = None
|
||||||
else:
|
else:
|
||||||
raise TypeError("Could not set csp_estimate with invalid type")
|
raise TypeError("Could not set csp_estimate with invalid type")
|
||||||
|
|
||||||
|
@ -58,3 +58,11 @@ class TestCSPEstimate:
|
|||||||
to = TaskOrder()
|
to = TaskOrder()
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
to.csp_estimate = "invalid"
|
to.csp_estimate = "invalid"
|
||||||
|
|
||||||
|
def test_removing_estimate(self):
|
||||||
|
attachment = Attachment(filename="sample.pdf", object_name="sample")
|
||||||
|
to = TaskOrder(csp_estimate=attachment)
|
||||||
|
assert to.csp_estimate is not None
|
||||||
|
|
||||||
|
to.csp_estimate = ""
|
||||||
|
assert to.csp_estimate is None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user