Merge pull request #1168 from dod-ccpo/bugfix/sort_environments
Bugfix: Ensure environment names are sorted when rendered
This commit is contained in:
@@ -16,7 +16,11 @@ 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,
|
||||
filter_env_roles_data,
|
||||
get_environments_obj_for_app,
|
||||
)
|
||||
|
||||
from tests.utils import captured_templates
|
||||
|
||||
@@ -132,6 +136,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(
|
||||
@@ -620,3 +637,21 @@ def test_filter_environment_roles():
|
||||
assert invite.is_revoked
|
||||
assert app_role.status == ApplicationRoleStatus.PENDING
|
||||
assert app_role.latest_invitation.email == "an_email@example.com"
|
||||
|
||||
|
||||
def test_filter_env_roles_data():
|
||||
env_a = EnvironmentFactory.create(name="a")
|
||||
env_b = EnvironmentFactory.create(name="b")
|
||||
env_c = EnvironmentFactory.create(name="c")
|
||||
|
||||
env_role_a = EnvironmentRoleFactory.create(environment=env_a)
|
||||
env_role_b = EnvironmentRoleFactory.create(environment=env_b)
|
||||
env_role_c = EnvironmentRoleFactory.create(environment=env_c)
|
||||
|
||||
env_role_data = filter_env_roles_data([env_role_b, env_role_c, env_role_a])
|
||||
|
||||
# test that the environments are sorted in alphabetical order by name. Since
|
||||
# we're just testing if the names are sorted, in this case we don't need to
|
||||
# ensure that the environment roles and environments are associated with the
|
||||
# same application.
|
||||
assert [env["environment_name"] for env in env_role_data] == ["a", "b", "c"]
|
||||
|
Reference in New Issue
Block a user