Raise error if csp estimate is not of proper type
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
from werkzeug.datastructures import FileStorage
|
||||
import pytest
|
||||
|
||||
from atst.models.attachment import Attachment
|
||||
from atst.models.task_order import TaskOrder, Status
|
||||
|
||||
from tests.factories import random_future_date, random_past_date
|
||||
from tests.mocks import PDF_FILENAME
|
||||
|
||||
|
||||
class TestTaskOrderStatus:
|
||||
@@ -30,3 +35,26 @@ def test_is_submitted():
|
||||
|
||||
to = TaskOrder(number="42")
|
||||
assert to.is_submitted
|
||||
|
||||
|
||||
class TestCSPEstimate:
|
||||
def test_setting_estimate_with_attachment(self):
|
||||
to = TaskOrder()
|
||||
attachment = Attachment(filename="sample.pdf", object_name="sample")
|
||||
to.csp_estimate = attachment
|
||||
|
||||
assert to.attachment_id == attachment.id
|
||||
|
||||
def test_setting_estimate_with_file_storage(self):
|
||||
to = TaskOrder()
|
||||
with open(PDF_FILENAME, "rb") as fp:
|
||||
fs = FileStorage(fp, content_type="application/pdf")
|
||||
to.csp_estimate = fs
|
||||
|
||||
assert to.csp_estimate is not None
|
||||
assert to.csp_estimate.filename == PDF_FILENAME
|
||||
|
||||
def test_setting_estimate_with_invalid_object(self):
|
||||
to = TaskOrder()
|
||||
with pytest.raises(TypeError):
|
||||
to.csp_estimate = "invalid"
|
||||
|
Reference in New Issue
Block a user