From d51bebf41a7aad10f96fb5391f340a3bb7826eb2 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Fri, 4 Oct 2019 20:34:06 +0200 Subject: [PATCH] [FIX] Make sure the generated view is always the same and the order of the button does not change randomly --- .../models/server_env_mixin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server_environment_data_encryption/models/server_env_mixin.py b/server_environment_data_encryption/models/server_env_mixin.py index 8f43799..d6e16ed 100644 --- a/server_environment_data_encryption/models/server_env_mixin.py +++ b/server_environment_data_encryption/models/server_env_mixin.py @@ -118,13 +118,17 @@ class ServerEnvMixin(models.AbstractModel): current_env = self.env.context.get("environment") or config.get( "running_env" ) - other_environments = [ + # Important to keep this list sorted. It makes sure the button to + # switch environment will always be in the same order. (more user + # friendly) and the test would fail without it as the order could + # change randomly and the view would then also change randomly + other_environments = sorted([ key[15:] for key, val in config.options.items() if key.startswith("encryption_key_") and val and key[15:] != current_env - ] + ]) if not current_env: raise ValidationError(