Update existing tests for new CLIN logic

- Factory adds total_amount field, which is always greater than obligated
field
- add total_amount field on tests that create TOs manually
- update tests that calculate total_contract_amount and
total_obligated_amount
This commit is contained in:
graham-dds 2019-09-11 11:52:25 -04:00
parent 0abd46eb4f
commit 2af0a2ecaf
5 changed files with 21 additions and 5 deletions

View File

@ -84,6 +84,7 @@ def test_create_adds_clins():
"start_date": date(2020, 1, 1), "start_date": date(2020, 1, 1),
"end_date": date(2021, 1, 1), "end_date": date(2021, 1, 1),
"obligated_amount": Decimal("5000"), "obligated_amount": Decimal("5000"),
"total_amount": Decimal("10000"),
}, },
{ {
"jedi_clin_type": "JEDI_CLIN_1", "jedi_clin_type": "JEDI_CLIN_1",
@ -91,6 +92,7 @@ def test_create_adds_clins():
"start_date": date(2020, 1, 1), "start_date": date(2020, 1, 1),
"end_date": date(2021, 1, 1), "end_date": date(2021, 1, 1),
"obligated_amount": Decimal("5000"), "obligated_amount": Decimal("5000"),
"total_amount": Decimal("10000"),
}, },
] ]
task_order = TaskOrders.create( task_order = TaskOrders.create(
@ -113,6 +115,7 @@ def test_update_adds_clins():
"start_date": date(2020, 1, 1), "start_date": date(2020, 1, 1),
"end_date": date(2021, 1, 1), "end_date": date(2021, 1, 1),
"obligated_amount": Decimal("5000"), "obligated_amount": Decimal("5000"),
"total_amount": Decimal("10000"),
}, },
{ {
"jedi_clin_type": "JEDI_CLIN_1", "jedi_clin_type": "JEDI_CLIN_1",
@ -120,6 +123,7 @@ def test_update_adds_clins():
"start_date": date(2020, 1, 1), "start_date": date(2020, 1, 1),
"end_date": date(2021, 1, 1), "end_date": date(2021, 1, 1),
"obligated_amount": Decimal("5000"), "obligated_amount": Decimal("5000"),
"total_amount": Decimal("10000"),
}, },
] ]
task_order = TaskOrders.create( task_order = TaskOrders.create(
@ -144,6 +148,7 @@ def test_update_does_not_duplicate_clins():
"start_date": date(2020, 1, 1), "start_date": date(2020, 1, 1),
"end_date": date(2021, 1, 1), "end_date": date(2021, 1, 1),
"obligated_amount": Decimal("5000"), "obligated_amount": Decimal("5000"),
"total_amount": Decimal("10000"),
}, },
{ {
"jedi_clin_type": "JEDI_CLIN_1", "jedi_clin_type": "JEDI_CLIN_1",
@ -151,6 +156,7 @@ def test_update_does_not_duplicate_clins():
"start_date": date(2020, 1, 1), "start_date": date(2020, 1, 1),
"end_date": date(2021, 1, 1), "end_date": date(2021, 1, 1),
"obligated_amount": Decimal("5000"), "obligated_amount": Decimal("5000"),
"total_amount": Decimal("10000"),
}, },
] ]
task_order = TaskOrders.update( task_order = TaskOrders.update(

View File

@ -291,8 +291,8 @@ class CLINFactory(Base):
number = factory.LazyFunction(random_task_order_number) number = factory.LazyFunction(random_task_order_number)
start_date = datetime.date.today() start_date = datetime.date.today()
end_date = factory.LazyFunction(random_future_date) end_date = factory.LazyFunction(random_future_date)
total_amount = factory.LazyFunction(lambda *args: random.randint(100, 999999)) total_amount = factory.LazyFunction(lambda *args: random.randint(50000, 999999))
obligated_amount = factory.LazyFunction(lambda *args: random.randint(100, 999999)) obligated_amount = factory.LazyFunction(lambda *args: random.randint(100, 50000))
jedi_clin_type = factory.LazyFunction( jedi_clin_type = factory.LazyFunction(
lambda *args: random.choice(list(clin.JEDICLINType)) lambda *args: random.choice(list(clin.JEDICLINType))
) )

View File

@ -152,19 +152,23 @@ class TestBudget:
assert ( assert (
to.total_contract_amount to.total_contract_amount
== clin1.obligated_amount + clin2.obligated_amount + clin3.obligated_amount == clin1.total_amount + clin2.total_amount + clin3.total_amount
) )
def test_total_obligated_funds(self): def test_total_obligated_funds(self):
to = TaskOrder() to = TaskOrder()
clin4 = CLINFactory(task_order=to, jedi_clin_type=JEDICLINType.JEDI_CLIN_4)
assert to.total_obligated_funds == 0 assert to.total_obligated_funds == 0
clin1 = CLINFactory(task_order=to, jedi_clin_type=JEDICLINType.JEDI_CLIN_1) clin1 = CLINFactory(task_order=to, jedi_clin_type=JEDICLINType.JEDI_CLIN_1)
clin2 = CLINFactory(task_order=to, jedi_clin_type=JEDICLINType.JEDI_CLIN_2) clin2 = CLINFactory(task_order=to, jedi_clin_type=JEDICLINType.JEDI_CLIN_2)
clin3 = CLINFactory(task_order=to, jedi_clin_type=JEDICLINType.JEDI_CLIN_3) clin3 = CLINFactory(task_order=to, jedi_clin_type=JEDICLINType.JEDI_CLIN_3)
clin4 = CLINFactory(task_order=to, jedi_clin_type=JEDICLINType.JEDI_CLIN_4)
assert ( assert (
to.total_obligated_funds == clin1.obligated_amount + clin3.obligated_amount to.total_obligated_funds
== clin1.obligated_amount
+ clin2.obligated_amount
+ clin3.obligated_amount
+ clin4.obligated_amount
) )

View File

@ -194,11 +194,13 @@ def test_task_orders_submit_form_step_three_add_clins(client, user_session, task
"clins-0-start_date": "01/01/2020", "clins-0-start_date": "01/01/2020",
"clins-0-end_date": "01/01/2021", "clins-0-end_date": "01/01/2021",
"clins-0-obligated_amount": "5000", "clins-0-obligated_amount": "5000",
"clins-0-total_amount": "10000",
"clins-1-jedi_clin_type": "JEDI_CLIN_1", "clins-1-jedi_clin_type": "JEDI_CLIN_1",
"clins-1-number": "12312", "clins-1-number": "12312",
"clins-1-start_date": "01/01/2020", "clins-1-start_date": "01/01/2020",
"clins-1-end_date": "01/01/2021", "clins-1-end_date": "01/01/2021",
"clins-1-obligated_amount": "5000", "clins-1-obligated_amount": "5000",
"clins-1-total_amount": "5000",
} }
response = client.post( response = client.post(
url_for( url_for(
@ -221,6 +223,7 @@ def test_task_orders_submit_form_step_three_add_clins_existing_to(
"start_date": "01/01/2020", "start_date": "01/01/2020",
"end_date": "01/01/2021", "end_date": "01/01/2021",
"obligated_amount": "5000", "obligated_amount": "5000",
"total_amount": "10000",
}, },
{ {
"jedi_clin_type": "JEDI_CLIN_1", "jedi_clin_type": "JEDI_CLIN_1",
@ -228,6 +231,7 @@ def test_task_orders_submit_form_step_three_add_clins_existing_to(
"start_date": "01/01/2020", "start_date": "01/01/2020",
"end_date": "01/01/2021", "end_date": "01/01/2021",
"obligated_amount": "5000", "obligated_amount": "5000",
"total_amount": "10000",
}, },
] ]
TaskOrders.create_clins(task_order.id, clin_list) TaskOrders.create_clins(task_order.id, clin_list)
@ -240,6 +244,7 @@ def test_task_orders_submit_form_step_three_add_clins_existing_to(
"clins-0-start_date": "01/01/2020", "clins-0-start_date": "01/01/2020",
"clins-0-end_date": "01/01/2021", "clins-0-end_date": "01/01/2021",
"clins-0-obligated_amount": "5000", "clins-0-obligated_amount": "5000",
"clins-0-total_amount": "10000",
} }
response = client.post( response = client.post(
url_for( url_for(

View File

@ -530,6 +530,7 @@ def test_task_orders_new_post_routes(post_url_assert_status):
"clins-0-start_date": "01/01/2020", "clins-0-start_date": "01/01/2020",
"clins-0-end_date": "01/01/2021", "clins-0-end_date": "01/01/2021",
"clins-0-obligated_amount": "5000", "clins-0-obligated_amount": "5000",
"clins-0-total_amount": "10000",
}, },
), ),
] ]