From 045dcef6f98123f810a7cf6537b414c95b580cd4 Mon Sep 17 00:00:00 2001 From: Patrick Smith Date: Wed, 23 Jan 2019 16:30:28 -0500 Subject: [PATCH] Handle submitting form without csp estimate --- atst/models/task_order.py | 2 +- tests/models/test_task_order.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/atst/models/task_order.py b/atst/models/task_order.py index d1d32206..846f1fbc 100644 --- a/atst/models/task_order.py +++ b/atst/models/task_order.py @@ -88,7 +88,7 @@ class TaskOrder(Base, mixins.TimestampsMixin): ) elif not new_csp_estimate and self._csp_estimate: self._csp_estimate = None - else: + elif new_csp_estimate: raise TypeError("Could not set csp_estimate with invalid type") @property diff --git a/tests/models/test_task_order.py b/tests/models/test_task_order.py index 447ad258..62ebcfaf 100644 --- a/tests/models/test_task_order.py +++ b/tests/models/test_task_order.py @@ -59,6 +59,13 @@ class TestCSPEstimate: with pytest.raises(TypeError): to.csp_estimate = "invalid" + def test_setting_estimate_with_empty_value(self): + to = TaskOrder() + assert to.csp_estimate is None + + to.csp_estimate = "" + assert to.csp_estimate is None + def test_removing_estimate(self): attachment = Attachment(filename="sample.pdf", object_name="sample") to = TaskOrder(csp_estimate=attachment)