Fix tests and formatting

This commit is contained in:
leigh-mil 2019-06-10 10:57:44 -04:00
parent 42970ded6f
commit 46cd8f3762
7 changed files with 19 additions and 16 deletions

View File

@ -1,6 +1,13 @@
from wtforms.fields import BooleanField, DecimalField, FieldList, FileField, FormField, StringField from wtforms.fields import (
BooleanField,
DecimalField,
FieldList,
FileField,
FormField,
StringField,
)
from wtforms.fields.html5 import DateField from wtforms.fields.html5 import DateField
from wtforms.validators import Required, Optional from wtforms.validators import Required
from flask_wtf.file import FileAllowed from flask_wtf.file import FileAllowed
from flask_wtf import FlaskForm from flask_wtf import FlaskForm

View File

@ -130,9 +130,7 @@ class TaskOrder(Base, mixins.TimestampsMixin):
return { return {
"portfolio_name": self.portfolio_name, "portfolio_name": self.portfolio_name,
"pdf": self.pdf, "pdf": self.pdf,
"clins": [ "clins": [clin.to_dictionary() for clin in self.clins],
clin.to_dictionary() for clin in self.clins
],
**{ **{
c.name: getattr(self, c.name) c.name: getattr(self, c.name)
for c in self.__table__.columns for c in self.__table__.columns

View File

@ -13,9 +13,7 @@ def render_task_orders_edit(portfolio_id, task_order_id=None, form=None):
if task_order_id: if task_order_id:
task_order = TaskOrders.get(task_order_id) task_order = TaskOrders.get(task_order_id)
render_args["form"] = form or TaskOrderForm( render_args["form"] = form or TaskOrderForm(**task_order.to_dictionary())
**task_order.to_dictionary()
)
render_args["task_order_id"] = task_order_id render_args["task_order_id"] = task_order_id
else: else:
render_args["form"] = form or TaskOrderForm() render_args["form"] = form or TaskOrderForm()

View File

@ -14,6 +14,6 @@ export default {
}, },
data: function() { data: function() {
return {clinIndex: this.initialClinIndex} return { clinIndex: this.initialClinIndex }
}, },
} }

View File

@ -19,7 +19,7 @@ export default {
initialyear: { type: String }, initialyear: { type: String },
mindate: { type: String }, mindate: { type: String },
maxdate: { type: String }, maxdate: { type: String },
nameTag: { type: String } nameTag: { type: String },
}, },
data: function() { data: function() {

View File

@ -30,8 +30,6 @@ export default {
clins, clins,
clinIndex, clinIndex,
} }
// pass initialCLINIndex in props and add one each time a clin is added...
// this way we can keep track of the clin id for the html name/id/etc
}, },
methods: { methods: {

View File

@ -55,7 +55,7 @@ def test_all_sections_complete():
assert TaskOrders.all_sections_complete(task_order) assert TaskOrders.all_sections_complete(task_order)
def test_create_adds_clins(): def test_create_adds_clins(pdf_upload):
portfolio = PortfolioFactory.create() portfolio = PortfolioFactory.create()
clins = [ clins = [
{ {
@ -80,11 +80,12 @@ def test_create_adds_clins():
portfolio_id=portfolio.id, portfolio_id=portfolio.id,
number="0123456789", number="0123456789",
clins=clins, clins=clins,
pdf=pdf_upload,
) )
assert len(task_order.clins) == 2 assert len(task_order.clins) == 2
def test_update_adds_clins(): def test_update_adds_clins(pdf_upload):
task_order = TaskOrderFactory.create(number="1231231234") task_order = TaskOrderFactory.create(number="1231231234")
to_number = task_order.number to_number = task_order.number
clins = [ clins = [
@ -110,12 +111,13 @@ def test_update_adds_clins():
portfolio_id=task_order.portfolio_id, portfolio_id=task_order.portfolio_id,
number="0000000000", number="0000000000",
clins=clins, clins=clins,
pdf=pdf_upload,
) )
assert task_order.number != to_number assert task_order.number != to_number
assert len(task_order.clins) == 2 assert len(task_order.clins) == 2
def test_update_does_not_duplicate_clins(): def test_update_does_not_duplicate_clins(pdf_upload):
task_order = TaskOrderFactory.create(number="3453453456", clins=["123", "456"]) task_order = TaskOrderFactory.create(number="3453453456", clins=["123", "456"])
clins = [ clins = [
{ {
@ -136,7 +138,7 @@ def test_update_does_not_duplicate_clins():
}, },
] ]
task_order = TaskOrders.update( task_order = TaskOrders.update(
task_order_id=task_order.id, number="0000000000", clins=clins task_order_id=task_order.id, number="0000000000", clins=clins, pdf=pdf_upload
) )
assert len(task_order.clins) == 2 assert len(task_order.clins) == 2
for clin in task_order.clins: for clin in task_order.clins: