Best Python code snippet using localstack_python
config_listener.py
Source:config_listener.py
...6from localstack import config, constants7from localstack.services.generic_proxy import ProxyListener8LOG = logging.getLogger(__name__)9CONFIG_LISTENERS: List[Callable[[str, str], None]] = []10def trigger_config_listeners(variable, new_value):11 LOG.debug("Updating config listeners")12 for listener in CONFIG_LISTENERS:13 listener(variable, new_value)14def update_config_variable(variable, new_value):15 if new_value is not None:16 LOG.info('Updating value of config variable "%s": %s', variable, new_value)17 setattr(config, variable, new_value)18 trigger_config_listeners(variable, new_value)19class ConfigUpdateProxyListener(ProxyListener):20 """Default proxy listener that intercepts requests to retrieve or update config variables."""21 def forward_request(self, method, path, data, headers):22 if path != constants.CONFIG_UPDATE_PATH or method != "POST":23 return True24 response = Response()25 data = json.loads(data)26 variable = data.get("variable", "")27 response._content = "{}"28 response.status_code = 20029 if not re.match(r"^[_a-zA-Z0-9]+$", variable):30 response.status_code = 40031 return response32 new_value = data.get("value")...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!