Add New Portfolio Workflow
This commit is contained in:
@@ -106,6 +106,13 @@ class PortfolioFactory(Base):
|
||||
name = factory.Faker("domain_word")
|
||||
defense_component = factory.LazyFunction(random_service_branch)
|
||||
|
||||
app_migration = random_choice(data.APP_MIGRATION)
|
||||
complexity = [random_choice(data.APPLICATION_COMPLEXITY)]
|
||||
description = factory.Faker("sentence")
|
||||
dev_team = [random_choice(data.DEV_TEAM)]
|
||||
native_apps = random.choice(["yes", "no", "not_sure"])
|
||||
team_experience = random_choice(data.TEAM_EXPERIENCE)
|
||||
|
||||
@classmethod
|
||||
def _create(cls, model_class, *args, **kwargs):
|
||||
with_applications = kwargs.pop("applications", [])
|
||||
|
||||
@@ -8,6 +8,59 @@ from tests.factories import (
|
||||
UserFactory,
|
||||
)
|
||||
from atst.utils.localization import translate
|
||||
from atst.domain.portfolios import Portfolios
|
||||
from atst.domain.portfolios.query import PortfoliosQuery
|
||||
|
||||
|
||||
def test_new_portfolio(client, user_session):
|
||||
user = UserFactory.create()
|
||||
user_session(user)
|
||||
|
||||
response = client.get(url_for("portfolios.new_portfolio"))
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_create_portfolio_success(client, user_session):
|
||||
user = UserFactory.create()
|
||||
user_session(user)
|
||||
|
||||
original_portfolio_count = len(PortfoliosQuery.get_all())
|
||||
|
||||
response = client.post(
|
||||
url_for("portfolios.create_portfolio"),
|
||||
data={
|
||||
"name": "My project name",
|
||||
"description": "My project description",
|
||||
"defense_component": "Air Force, Department of the",
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 302
|
||||
assert len(PortfoliosQuery.get_all()) == original_portfolio_count + 1
|
||||
|
||||
new_portfolio = Portfolios.for_user(user=user)[-1]
|
||||
|
||||
assert (
|
||||
url_for("applications.portfolio_applications", portfolio_id=new_portfolio.id)
|
||||
in response.location
|
||||
)
|
||||
assert new_portfolio.owner == user
|
||||
|
||||
|
||||
def test_create_portfolio_failure(client, user_session):
|
||||
user = UserFactory.create()
|
||||
user_session(user)
|
||||
|
||||
original_portfolio_count = len(PortfoliosQuery.get_all())
|
||||
|
||||
response = client.post(
|
||||
url_for("portfolios.create_portfolio"),
|
||||
data={"name": "My project name", "description": "My project description"},
|
||||
)
|
||||
|
||||
assert response.status_code == 400
|
||||
assert len(PortfoliosQuery.get_all()) == original_portfolio_count
|
||||
|
||||
|
||||
def test_portfolio_index_with_existing_portfolios(client, user_session):
|
||||
|
||||
@@ -26,6 +26,8 @@ _NO_ACCESS_CHECK_REQUIRED = _NO_LOGIN_REQUIRED + [
|
||||
"applications.accept_invitation", # available to all users; access control is built into invitation logic
|
||||
"atst.catch_all", # available to all users
|
||||
"portfolios.portfolios", # the portfolios list is scoped to the user separately
|
||||
"portfolios.new_portfolio", # all users can create a portfolio
|
||||
"portfolios.create_portfolio", # create a portfolio
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user