How to use get_deployment_config method in localstack

Best Python code snippet using localstack_python

test_common.py

Source:test_common.py Github

copy

Full Screen

...11 json_file = format_path("../deployment-configs/01-json-test.json")12 yaml_file = format_path("../deployment-configs/01-yaml-test.yaml")13 jinja_json_file = format_path("../deployment-configs/01-jinja-test.json.j2")14 jinja_yaml_file = format_path("../deployment-configs/01-jinja-test.yaml.j2")15 json_default_envs = get_deployment_config(json_file).get_all_environment_names()16 yaml_default_envs = get_deployment_config(yaml_file).get_all_environment_names()17 jinja_json_default_envs = get_deployment_config(jinja_json_file).get_all_environment_names()18 jinja_yaml_default_envs = get_deployment_config(jinja_yaml_file).get_all_environment_names()19 assert json_default_envs == yaml_default_envs == jinja_json_default_envs == jinja_yaml_default_envs20 def test_all_file_formats_contents_match(self):21 json_file = format_path("../deployment-configs/01-json-test.json")22 yaml_file = format_path("../deployment-configs/01-yaml-test.yaml")23 jinja_json_file = format_path("../deployment-configs/01-jinja-test.json.j2")24 jinja_yaml_file = format_path("../deployment-configs/01-jinja-test.yaml.j2")25 json_default_env = get_deployment_config(json_file).get_environment("default")26 yaml_default_env = get_deployment_config(yaml_file).get_environment("default")27 jinja_json_default_env = get_deployment_config(jinja_json_file).get_environment("default")28 jinja_yaml_default_env = get_deployment_config(jinja_yaml_file).get_environment("default")29 assert yaml_default_env == json_default_env == jinja_json_default_env == jinja_yaml_default_env30 def test_all_file_formats_variables_match(self):31 json_file = format_path("../deployment-configs/02-json-with-vars-test.json")32 yaml_file = format_path("../deployment-configs/02-yaml-with-vars-test.yaml")33 jinja_json_file = format_path("../deployment-configs/02-jinja-with-vars-test.json.j2")34 jinja_yaml_file = format_path("../deployment-configs/02-jinja-with-vars-test.yaml.j2")35 json_default_env = get_deployment_config(json_file).get_environment("default")36 yaml_default_env = get_deployment_config(yaml_file).get_environment("default")37 jinja_json_default_env = get_deployment_config(jinja_json_file).get_environment("default")38 jinja_yaml_default_env = get_deployment_config(jinja_yaml_file).get_environment("default")39 assert yaml_default_env == json_default_env == jinja_json_default_env == jinja_yaml_default_env40 @mock.patch.dict(os.environ, {"TIMEOUT": "100"}, clear=True)41 def test_json_file_with_env_variables_scalar_type(self):42 """43 JSON: Simple Scalar (key-value) type for timeout_seconds parameter44 """45 json_file = format_path("../deployment-configs/04-json-with-env-vars.json")46 json_default_envs = get_deployment_config(json_file).get_environment("default")47 timeout_seconds = json_default_envs.get("jobs")[0].get("timeout_seconds")48 self.assertEqual(int(timeout_seconds), 100)49 @mock.patch.dict(os.environ, {"ALERT_EMAIL": "test@test.com"}, clear=True)50 def test_json_file_with_env_variables_array_type(self):51 """52 JSON:53 In email_notification.on_failure, one email has been set via env variables54 The other email has been pre-set in deployment.yaml55 """56 json_file = format_path("../deployment-configs/04-json-with-env-vars.json")57 json_default_envs = get_deployment_config(json_file).get_environment("default")58 emails = json_default_envs.get("jobs")[0].get("email_notifications").get("on_failure")59 env_email_value = emails[0]60 preset_email = emails[1]61 self.assertEqual(env_email_value, "test@test.com")62 self.assertEqual(preset_email, "presetEmail@test.com")63 def test_json_file_with_env_variables_default_values_with_braces(self):64 """65 JSON:66 max_retries is set to ${MAX_RETRY:3} i.e. with braces67 MAX_RETRY env var will not be set. It should default to 368 based on config in deployment file69 """70 # MAX_RETRY not set71 json_file = format_path("../deployment-configs/04-json-with-env-vars.json")72 json_default_envs = get_deployment_config(json_file).get_environment("default")73 max_retries = json_default_envs.get("jobs")[0].get("max_retries")74 self.assertEqual(int(max_retries), 3)75 def test_json_file_with_env_variables_default_values_without_braces(self):76 """77 JSON:78 aws_attributes.availability is set to $AVAILABILITY:SPOT i.e. without braces79 AVAILABILITY env var will not be set. It should default to SPOT80 based on config in deployment file81 """82 # AVAILABILITY not set83 json_file = format_path("../deployment-configs/04-json-with-env-vars.json")84 json_default_envs = get_deployment_config(json_file).get_environment("default")85 availability = json_default_envs.get("jobs")[0].get("new_cluster").get("aws_attributes").get("availability")86 self.assertEqual(availability, "SPOT")87 @mock.patch.dict(os.environ, {"TIMEOUT": "100"}, clear=True)88 def test_yaml_file_with_env_variables_scalar_type(self):89 """90 YAML: Simple Scalar (key-value) type for timeout_seconds parameter91 """92 yaml_file = format_path("../deployment-configs/04-yaml-with-env-vars.yaml")93 yaml_default_envs = get_deployment_config(yaml_file).get_environment("default")94 timeout_seconds = yaml_default_envs.get("jobs")[0].get("timeout_seconds")95 self.assertEqual(int(timeout_seconds), 100)96 @mock.patch.dict(os.environ, {"ALERT_EMAIL": "test@test.com"}, clear=True)97 def test_yaml_file_with_env_variables_array_type(self):98 """99 YAML:100 In email_notification.on_failure, one email has been set via env variables101 The other email has been pre-set in deployment.yaml102 """103 yaml_file = format_path("../deployment-configs/04-yaml-with-env-vars.yaml")104 yaml_default_envs = get_deployment_config(yaml_file).get_environment("default")105 emails = yaml_default_envs.get("jobs")[0].get("email_notifications").get("on_failure")106 env_email_value = emails[0]107 preset_email = emails[1]108 self.assertEqual(env_email_value, "test@test.com")109 self.assertEqual(preset_email, "presetEmail@test.com")110 def test_yaml_file_with_env_variables_default_values(self):111 """112 YAML:113 MAX_RETRY env var will not be set. It should default to 3114 based on config in deployment file115 """116 # MAX_RETRY not set117 yaml_file = format_path("../deployment-configs/04-yaml-with-env-vars.yaml")118 yaml_default_envs = get_deployment_config(yaml_file).get_environment("default")119 max_retries = yaml_default_envs.get("jobs")[0].get("max_retries")120 self.assertEqual(int(max_retries), 3)121 @mock.patch.dict(os.environ, {"TIMEOUT": "100"}, clear=True)122 def test_jinja_files_with_env_variables_scalar_type(self):123 """124 JINJA2: Simple Scalar (key-value) type for timeout_seconds parameter125 """126 json_j2_file = format_path("../deployment-configs/04-jinja-with-env-vars.json.j2")127 yaml_j2_file = format_path("../deployment-configs/04-jinja-with-env-vars.yaml.j2")128 json_default_envs = get_deployment_config(json_j2_file).get_environment("default")129 yaml_default_envs = get_deployment_config(yaml_j2_file).get_environment("default")130 json_timeout_seconds = json_default_envs.get("jobs")[0].get("timeout_seconds")131 yaml_timeout_seconds = yaml_default_envs.get("jobs")[0].get("timeout_seconds")132 self.assertEqual(int(json_timeout_seconds), 100)133 self.assertEqual(int(yaml_timeout_seconds), 100)134 @mock.patch.dict(os.environ, {"ALERT_EMAIL": "test@test.com"}, clear=True)135 def test_jinja_files_with_env_variables_array_type(self):136 """137 JINJA2: In email_notification.on_failure, the first email has been set via env variables138 """139 json_j2_file = format_path("../deployment-configs/04-jinja-with-env-vars.json.j2")140 yaml_j2_file = format_path("../deployment-configs/04-jinja-with-env-vars.yaml.j2")141 json_default_envs = get_deployment_config(json_j2_file).get_environment("default")142 yaml_default_envs = get_deployment_config(yaml_j2_file).get_environment("default")143 json_emails = json_default_envs.get("jobs")[0].get("email_notifications").get("on_failure")144 yaml_emails = yaml_default_envs.get("jobs")[0].get("email_notifications").get("on_failure")145 self.assertEqual(json_emails, yaml_emails)146 self.assertEqual(json_emails[0], "test@test.com")147 def test_jinja_file_with_env_variables_default_values(self):148 """149 JINJA:150 max_retries is set to {{ MAX_RETRY | default(3) }};151 new_cluster.aws_attributes.availability is set to {{ AVAILABILITY | default('SPOT') }}.152 MAX_RETRY and AVAILABILITY env vars will not be set. They should default to 3 and 'SPOT'153 based on config in deployment file154 """155 json_j2_file = format_path("../deployment-configs/04-jinja-with-env-vars.json.j2")156 yaml_j2_file = format_path("../deployment-configs/04-jinja-with-env-vars.yaml.j2")157 json_default_envs = get_deployment_config(json_j2_file).get_environment("default")158 yaml_default_envs = get_deployment_config(yaml_j2_file).get_environment("default")159 json_max_retries = json_default_envs.get("jobs")[0].get("max_retries")160 yaml_max_retries = yaml_default_envs.get("jobs")[0].get("max_retries")161 json_avail = json_default_envs.get("jobs")[0].get("new_cluster").get("aws_attributes").get("availability")162 yaml_avail = yaml_default_envs.get("jobs")[0].get("new_cluster").get("aws_attributes").get("availability")163 self.assertEqual(int(json_max_retries), int(yaml_max_retries))164 self.assertEqual(int(json_max_retries), 3)165 self.assertEqual(json_avail, yaml_avail)166 self.assertEqual(json_avail, "SPOT")167 @mock.patch.dict(os.environ, {"ENVIRONMENT": "PRODUCTION"}, clear=True)168 def test_jinja_files_with_env_variables_logic_1(self):169 """170 JINJA:171 - max_retries is set to {{ MAX_RETRY | default(-1) }} if (ENVIRONMENT.lower() == "production"),172 {{ MAX_RETRY | default(3) }} otherwise.173 - email_notifications are only set if (ENVIRONMENT.lower() == "production").174 ENVIRONMENT is set to "production", so MAX_RETRY and EMAIL_NOTIFICATIONS env vars175 should correspond to the ENVIRONMENT=production values.176 Also testing filters like .lower() are working correctly.177 """178 json_j2_file = format_path("../deployment-configs/06-jinja-with-logic.json.j2")179 yaml_j2_file = format_path("../deployment-configs/06-jinja-with-logic.yaml.j2")180 json_default_envs = get_deployment_config(json_j2_file).get_environment("default")181 yaml_default_envs = get_deployment_config(yaml_j2_file).get_environment("default")182 json_max_retries = json_default_envs.get("jobs")[0].get("max_retries")183 yaml_max_retries = yaml_default_envs.get("jobs")[0].get("max_retries")184 json_emails = json_default_envs.get("jobs")[0].get("email_notifications").get("on_failure")185 yaml_emails = yaml_default_envs.get("jobs")[0].get("email_notifications").get("on_failure")186 self.assertEqual(int(json_max_retries), -1)187 self.assertEqual(int(yaml_max_retries), -1)188 self.assertEqual(json_emails[0], "presetEmail@test.com")189 self.assertEqual(yaml_emails[0], "presetEmail@test.com")190 @mock.patch.dict(os.environ, {"ENVIRONMENT": "test"}, clear=True)191 def test_jinja_files_with_env_variables_logic_2(self):192 """193 JINJA:194 - max_retries is set to {{ MAX_RETRY | default(-1) }} if (ENVIRONMENT == "production"),195 {{ MAX_RETRY | default(3) }} otherwise.196 - email_notifications are only set if (ENVIRONMENT == "production").197 ENVIRONMENT is set to "test", so MAX_RETRY and EMAIL_NOTIFICATIONS env vars198 should correspond to the ENVIRONMENT != production values.199 """200 json_j2_file = format_path("../deployment-configs/06-jinja-with-logic.json.j2")201 yaml_j2_file = format_path("../deployment-configs/06-jinja-with-logic.yaml.j2")202 json_default_envs = get_deployment_config(json_j2_file).get_environment("default")203 yaml_default_envs = get_deployment_config(yaml_j2_file).get_environment("default")204 json_max_retries = json_default_envs.get("jobs")[0].get("max_retries")205 yaml_max_retries = yaml_default_envs.get("jobs")[0].get("max_retries")206 json_emails = json_default_envs.get("jobs")[0].get("email_notifications")207 yaml_emails = yaml_default_envs.get("jobs")[0].get("email_notifications")208 self.assertEqual(int(json_max_retries), 3)209 self.assertEqual(int(yaml_max_retries), 3)210 self.assertEqual(json_emails, None)211 self.assertEqual(yaml_emails, None)212if __name__ == "__main__":...

Full Screen

Full Screen

get_deployment_config.py

Source:get_deployment_config.py Github

copy

Full Screen

...29 if False:30 yield self31 return GetDeploymentConfigResult(32 id=self.id)33def get_deployment_config(id: Optional[str] = None,34 opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetDeploymentConfigResult:35 """36 Resource Type definition for AWS::CodeDeploy::DeploymentConfig37 """38 __args__ = dict()39 __args__['id'] = id40 opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)41 __ret__ = pulumi.runtime.invoke('aws-native:codedeploy:getDeploymentConfig', __args__, opts=opts, typ=GetDeploymentConfigResult).value42 return AwaitableGetDeploymentConfigResult(43 id=__ret__.id)44@_utilities.lift_output_func(get_deployment_config)45def get_deployment_config_output(id: Optional[pulumi.Input[str]] = None,46 opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[GetDeploymentConfigResult]:47 """...

Full Screen

Full Screen

test_plan_assigner.py

Source:test_plan_assigner.py Github

copy

Full Screen

...30 assigned_communication_plan_ref = json.load(open(output_path, 'r'))31 assert(assigned_communication_plan == assigned_communication_plan_ref)32 # Check the get_deployment_config function33 # Test for wrong input34 assert(pa.get_deployment_config(None) is None)35 # functional test36 deployment_config, rank2ip = pa.get_deployment_config(37 assigned_communication_plan38 )39 assert(deployment_config == {"10.0.0.21": 2})...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful