Ensure environment names are sorted when rendered
This commit is contained in:
parent
7b96a05f95
commit
6bc1e0ba9a
@ -22,19 +22,22 @@ from atst.jobs import send_mail
|
||||
|
||||
|
||||
def get_environments_obj_for_app(application):
|
||||
environments_obj = []
|
||||
for env in application.environments:
|
||||
env_data = {
|
||||
"id": env.id,
|
||||
"name": env.name,
|
||||
"pending": env.is_pending,
|
||||
"edit_form": EditEnvironmentForm(obj=env),
|
||||
"member_count": len(env.roles),
|
||||
"members": [env_role.application_role.user_name for env_role in env.roles],
|
||||
}
|
||||
environments_obj.append(env_data)
|
||||
|
||||
return environments_obj
|
||||
return sorted(
|
||||
[
|
||||
{
|
||||
"id": env.id,
|
||||
"name": env.name,
|
||||
"pending": env.is_pending,
|
||||
"edit_form": EditEnvironmentForm(obj=env),
|
||||
"member_count": len(env.roles),
|
||||
"members": [
|
||||
env_role.application_role.user_name for env_role in env.roles
|
||||
],
|
||||
}
|
||||
for env in application.environments
|
||||
],
|
||||
key=lambda env: env["name"],
|
||||
)
|
||||
|
||||
|
||||
def filter_perm_sets_data(member):
|
||||
|
@ -16,7 +16,10 @@ from atst.models.permissions import Permissions
|
||||
from atst.forms.application import EditEnvironmentForm
|
||||
from atst.forms.application_member import UpdateMemberForm
|
||||
from atst.forms.data import ENV_ROLE_NO_ACCESS as NO_ACCESS
|
||||
from atst.routes.applications.settings import filter_env_roles_form_data
|
||||
from atst.routes.applications.settings import (
|
||||
filter_env_roles_form_data,
|
||||
get_environments_obj_for_app,
|
||||
)
|
||||
|
||||
from tests.utils import captured_templates
|
||||
|
||||
@ -132,6 +135,19 @@ def test_edit_application_environments_obj(app, client, user_session):
|
||||
assert isinstance(context["audit_events"], Paginator)
|
||||
|
||||
|
||||
def test_get_environments_obj_for_app(app, client, user_session):
|
||||
application = ApplicationFactory.create(
|
||||
environments=[{"name": "Naboo"}, {"name": "Endor"}, {"name": "Hoth"}]
|
||||
)
|
||||
environments_obj = get_environments_obj_for_app(application)
|
||||
|
||||
assert [environment["name"] for environment in environments_obj] == [
|
||||
"Endor",
|
||||
"Hoth",
|
||||
"Naboo",
|
||||
]
|
||||
|
||||
|
||||
def test_get_members_data(app, client, user_session):
|
||||
user = UserFactory.create()
|
||||
application = ApplicationFactory.create(
|
||||
|
Loading…
x
Reference in New Issue
Block a user