Fix failing tests
This commit is contained in:
parent
eb4f3f4871
commit
30ebebb13a
@ -5,6 +5,7 @@ from sqlalchemy import Column, Numeric, String, ForeignKey, Date, Integer
|
|||||||
from sqlalchemy.ext.hybrid import hybrid_property
|
from sqlalchemy.ext.hybrid import hybrid_property
|
||||||
from sqlalchemy.types import ARRAY
|
from sqlalchemy.types import ARRAY
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
from werkzeug.datastructures import FileStorage
|
||||||
|
|
||||||
from atst.models import Attachment, Base, types, mixins
|
from atst.models import Attachment, Base, types, mixins
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ class TaskOrder(Base, mixins.TimestampsMixin):
|
|||||||
def csp_estimate(self, new_csp_estimate):
|
def csp_estimate(self, new_csp_estimate):
|
||||||
if isinstance(new_csp_estimate, Attachment):
|
if isinstance(new_csp_estimate, Attachment):
|
||||||
self._csp_estimate = new_csp_estimate
|
self._csp_estimate = new_csp_estimate
|
||||||
else:
|
elif isinstance(new_csp_estimate, FileStorage):
|
||||||
self._csp_estimate = Attachment.attach(
|
self._csp_estimate = Attachment.attach(
|
||||||
new_csp_estimate, "task_order", self.id
|
new_csp_estimate, "task_order", self.id
|
||||||
)
|
)
|
||||||
|
@ -2,6 +2,7 @@ import pytest
|
|||||||
|
|
||||||
from atst.domain.task_orders import TaskOrders, TaskOrderError
|
from atst.domain.task_orders import TaskOrders, TaskOrderError
|
||||||
from atst.domain.exceptions import UnauthorizedError
|
from atst.domain.exceptions import UnauthorizedError
|
||||||
|
from atst.models.attachment import Attachment
|
||||||
|
|
||||||
from tests.factories import (
|
from tests.factories import (
|
||||||
TaskOrderFactory,
|
TaskOrderFactory,
|
||||||
@ -26,10 +27,18 @@ def test_is_section_complete():
|
|||||||
|
|
||||||
def test_all_sections_complete():
|
def test_all_sections_complete():
|
||||||
task_order = TaskOrderFactory.create()
|
task_order = TaskOrderFactory.create()
|
||||||
|
attachment = Attachment(
|
||||||
|
filename="sample_attachment",
|
||||||
|
object_name="sample",
|
||||||
|
resource="task_order",
|
||||||
|
resource_id=task_order.id,
|
||||||
|
)
|
||||||
|
|
||||||
|
custom_attrs = {"csp_estimate": attachment}
|
||||||
for attr_list in TaskOrders.SECTIONS.values():
|
for attr_list in TaskOrders.SECTIONS.values():
|
||||||
for attr in attr_list:
|
for attr in attr_list:
|
||||||
if not getattr(task_order, attr):
|
if not getattr(task_order, attr):
|
||||||
setattr(task_order, attr, "str12345")
|
setattr(task_order, attr, custom_attrs.get(attr, "str12345"))
|
||||||
|
|
||||||
task_order.scope = None
|
task_order.scope = None
|
||||||
assert not TaskOrders.all_sections_complete(task_order)
|
assert not TaskOrders.all_sections_complete(task_order)
|
||||||
|
@ -2,6 +2,7 @@ import pytest
|
|||||||
from flask import url_for
|
from flask import url_for
|
||||||
|
|
||||||
from atst.domain.task_orders import TaskOrders
|
from atst.domain.task_orders import TaskOrders
|
||||||
|
from atst.models.attachment import Attachment
|
||||||
from atst.routes.task_orders.new import ShowTaskOrderWorkflow, UpdateTaskOrderWorkflow
|
from atst.routes.task_orders.new import ShowTaskOrderWorkflow, UpdateTaskOrderWorkflow
|
||||||
|
|
||||||
from tests.factories import UserFactory, TaskOrderFactory, PortfolioFactory
|
from tests.factories import UserFactory, TaskOrderFactory, PortfolioFactory
|
||||||
@ -124,8 +125,11 @@ def test_task_order_form_shows_errors(client, user_session):
|
|||||||
def task_order():
|
def task_order():
|
||||||
user = UserFactory.create()
|
user = UserFactory.create()
|
||||||
portfolio = PortfolioFactory.create(owner=user)
|
portfolio = PortfolioFactory.create(owner=user)
|
||||||
|
attachment = Attachment(filename="sample_attachment", object_name="sample")
|
||||||
|
|
||||||
return TaskOrderFactory.create(creator=user, portfolio=portfolio)
|
return TaskOrderFactory.create(
|
||||||
|
creator=user, portfolio=portfolio, csp_estimate=attachment
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_show_task_order(task_order):
|
def test_show_task_order(task_order):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user