From 672c56232358c327304ea2070cee2078c50b0be9 Mon Sep 17 00:00:00 2001 From: Patrick Smith Date: Tue, 22 Jan 2019 13:05:04 -0500 Subject: [PATCH] Allow removing a csp estimate from a task order --- atst/models/task_order.py | 2 ++ tests/models/test_task_order.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/atst/models/task_order.py b/atst/models/task_order.py index ac860129..d1d32206 100644 --- a/atst/models/task_order.py +++ b/atst/models/task_order.py @@ -86,6 +86,8 @@ class TaskOrder(Base, mixins.TimestampsMixin): self._csp_estimate = Attachment.attach( new_csp_estimate, "task_order", self.id ) + elif not new_csp_estimate and self._csp_estimate: + self._csp_estimate = None else: raise TypeError("Could not set csp_estimate with invalid type") diff --git a/tests/models/test_task_order.py b/tests/models/test_task_order.py index 6cbfc082..447ad258 100644 --- a/tests/models/test_task_order.py +++ b/tests/models/test_task_order.py @@ -58,3 +58,11 @@ class TestCSPEstimate: to = TaskOrder() with pytest.raises(TypeError): 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