Update application environments
This commit is contained in:
@@ -187,3 +187,10 @@ def test_delete_environment(session):
|
||||
assert env_role.deleted
|
||||
# flushed the change
|
||||
assert not session.dirty
|
||||
|
||||
|
||||
def test_update_environment():
|
||||
environment = EnvironmentFactory.create()
|
||||
assert environment.name is not "name 2"
|
||||
Environments.update(environment, name="name 2")
|
||||
assert environment.name == "name 2"
|
||||
|
@@ -17,10 +17,36 @@ from atst.domain.permission_sets import PermissionSets
|
||||
from atst.domain.portfolios import Portfolios
|
||||
from atst.models.environment_role import CSPRole
|
||||
from atst.models.portfolio_role import Status as PortfolioRoleStatus
|
||||
from atst.forms.application import EditEnvironmentForm
|
||||
|
||||
from tests.utils import captured_templates
|
||||
|
||||
|
||||
def test_updating_application_environments(client, user_session):
|
||||
portfolio = PortfolioFactory.create()
|
||||
application = ApplicationFactory.create(portfolio=portfolio)
|
||||
environment = EnvironmentFactory.create(application=application)
|
||||
|
||||
user_session(portfolio.owner)
|
||||
|
||||
form_data = {"name": "new name a"}
|
||||
|
||||
response = client.post(
|
||||
url_for("applications.update_environment", environment_id=environment.id),
|
||||
data=form_data,
|
||||
)
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for(
|
||||
"applications.settings",
|
||||
application_id=application.id,
|
||||
_external=True,
|
||||
fragment="application-environments",
|
||||
_anchor="application-environments",
|
||||
)
|
||||
assert environment.name == "new name a"
|
||||
|
||||
|
||||
def test_application_settings(client, user_session):
|
||||
portfolio = PortfolioFactory.create()
|
||||
application = Applications.create(
|
||||
@@ -61,13 +87,14 @@ def test_edit_application_environments_obj(app, client, user_session):
|
||||
|
||||
assert response.status_code == 200
|
||||
_, context = templates[0]
|
||||
assert context["environments_obj"] == {
|
||||
env1.name: [
|
||||
{"name": user1.full_name, "role": env_role1.role},
|
||||
{"name": user2.full_name, "role": env_role2.role},
|
||||
],
|
||||
env2.name: [{"name": user1.full_name, "role": env_role3.role}],
|
||||
}
|
||||
|
||||
env_obj_1 = context["environments_obj"][env1.name]
|
||||
assert env_obj_1["id"] == env1.id
|
||||
assert isinstance(env_obj_1["edit_form"], EditEnvironmentForm)
|
||||
assert env_obj_1["members"] == [
|
||||
{"name": user1.full_name, "role": env_role1.role},
|
||||
{"name": user2.full_name, "role": env_role2.role},
|
||||
]
|
||||
|
||||
|
||||
def test_edit_app_serialize_env_member_form_data(app, client, user_session):
|
||||
|
@@ -547,6 +547,25 @@ def test_applications_update_access(post_url_assert_status):
|
||||
post_url_assert_status(rando, url, 404)
|
||||
|
||||
|
||||
# applications.update_environments
|
||||
def test_applications_update_environments(post_url_assert_status):
|
||||
ccpo = UserFactory.create_ccpo()
|
||||
dev = UserFactory.create()
|
||||
rando = UserFactory.create()
|
||||
|
||||
portfolio = PortfolioFactory.create(
|
||||
owner=dev,
|
||||
applications=[{"name": "Mos Eisley", "description": "Where Han shot first"}],
|
||||
)
|
||||
app = portfolio.applications[0]
|
||||
environment = EnvironmentFactory.create(application=app)
|
||||
|
||||
url = url_for("applications.update_environment", environment_id=environment.id)
|
||||
post_url_assert_status(dev, url, 302)
|
||||
post_url_assert_status(ccpo, url, 302)
|
||||
post_url_assert_status(rando, url, 404)
|
||||
|
||||
|
||||
# task_orders.view_task_order
|
||||
def test_task_orders_view_task_order_access(get_url_assert_status):
|
||||
ccpo = user_with(PermissionSets.VIEW_PORTFOLIO_FUNDING)
|
||||
|
Reference in New Issue
Block a user