add attachment model and task order relation to it

This commit is contained in:
dandds
2018-08-24 13:29:19 -04:00
committed by Montana
parent ef2e97713a
commit 54d1e7235b
9 changed files with 145 additions and 10 deletions

View File

@@ -0,0 +1,18 @@
import pytest
from werkzeug.datastructures import FileStorage
from atst.models.attachment import Attachment, AttachmentError
from tests.mocks import PDF_FILENAME
def test_attach(pdf_upload):
attachment = Attachment.attach(pdf_upload)
assert attachment.filename == PDF_FILENAME
def test_attach_raises():
with open(PDF_FILENAME, "rb") as fp:
fs = FileStorage(fp, content_type="something/else")
with pytest.raises(AttachmentError):
Attachment.attach(fs)