Add tests
This commit is contained in:
parent
e39f8d6fee
commit
93e593e50d
@ -1,5 +1,6 @@
|
||||
from flask import url_for
|
||||
import pytest
|
||||
from datetime import timedelta, date
|
||||
|
||||
from atst.domain.roles import Roles
|
||||
from atst.models.portfolio_role import Status as PortfolioStatus
|
||||
@ -16,7 +17,7 @@ from tests.utils import captured_templates
|
||||
|
||||
|
||||
class TestPortfolioFunding:
|
||||
def test_unfunded_portfolio(self, app, user_session):
|
||||
def test_portfolio_with_no_task_orders(self, app, user_session):
|
||||
portfolio = PortfolioFactory.create()
|
||||
user_session(portfolio.owner)
|
||||
|
||||
@ -66,6 +67,54 @@ class TestPortfolioFunding:
|
||||
assert context["funding_end_date"] is end_date
|
||||
assert context["total_balance"] == active_to1.budget + active_to2.budget
|
||||
|
||||
def test_expiring_and_funded_portfolio(self, app, user_session):
|
||||
portfolio = PortfolioFactory.create()
|
||||
user_session(portfolio.owner)
|
||||
|
||||
expiring_to = TaskOrderFactory.create(
|
||||
portfolio=portfolio,
|
||||
start_date=random_past_date(),
|
||||
end_date=(date.today() + timedelta(days=10)),
|
||||
number="42",
|
||||
)
|
||||
active_to = TaskOrderFactory.create(
|
||||
portfolio=portfolio,
|
||||
start_date=random_past_date(),
|
||||
end_date=random_future_date(year_min=1, year_max=2),
|
||||
number="43",
|
||||
)
|
||||
|
||||
with captured_templates(app) as templates:
|
||||
response = app.test_client().get(
|
||||
url_for("portfolios.portfolio_funding", portfolio_id=portfolio.id)
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
_, context = templates[0]
|
||||
assert context["funding_end_date"] is active_to.end_date
|
||||
assert context["funded"] == True
|
||||
|
||||
def test_expiring_and_unfunded_portfolio(self, app, user_session):
|
||||
portfolio = PortfolioFactory.create()
|
||||
user_session(portfolio.owner)
|
||||
|
||||
expiring_to = TaskOrderFactory.create(
|
||||
portfolio=portfolio,
|
||||
start_date=random_past_date(),
|
||||
end_date=(date.today() + timedelta(days=10)),
|
||||
number="42",
|
||||
)
|
||||
|
||||
with captured_templates(app) as templates:
|
||||
response = app.test_client().get(
|
||||
url_for("portfolios.portfolio_funding", portfolio_id=portfolio.id)
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
_, context = templates[0]
|
||||
assert context["funding_end_date"] is expiring_to.end_date
|
||||
assert context["funded"] == False
|
||||
|
||||
|
||||
def test_ko_can_view_task_order(client, user_session):
|
||||
portfolio = PortfolioFactory.create()
|
||||
|
Loading…
x
Reference in New Issue
Block a user