How to use _post_process_arg_name method in localstack

Best Python code snippet using localstack_python

op_router.py

Source: op_router.py Github

copy

Full Screen

...162 request_uri_variable = request_uri_variable.strip("+")163 # replace forbidden chars (not allowed in Werkzeug rule variable names) with their placeholder164 escaped_request_uri_variable = request_uri_variable.translate(_rule_replacement_table)165 return f"<{greedy_prefix}{escaped_request_uri_variable}>"166def _post_process_arg_name(arg_key: str) -> str:167 """168 Reverses previous manipulations to the path parameters names (like replacing forbidden characters with169 placeholders).170 :param arg_key: Path param key name extracted using Werkzeug rules171 :return: Post-processed ("un-sanitized") path param key172 """173 result = arg_key174 for original, substitution in _rule_replacements.items():175 result = result.replace(substitution, original)176 return result177def _create_service_map(service: ServiceModel) -> Map:178 """179 Creates a Werkzeug Map object with all rules necessary for the specific service.180 :param service: botocore service model to create the rules for181 :return: a Map instance which is used to perform the in-service operation routing182 """183 ops = [service.operation_model(op_name) for op_name in service.operation_names]184 rules = []185 # group all operations by their path and method186 path_index: Dict[(str, str), List[_HttpOperation]] = defaultdict(list)187 for op in ops:188 http_op = _HttpOperation.from_operation(op)189 path_index[(http_op.path, http_op.method)].append(http_op)190 # create a matching rule for each (path, method) combination191 for (path, method), ops in path_index.items():192 # translate the requestUri to a Werkzeug rule string193 rule_string = _path_param_regex.sub(_transform_path_params_to_rule_vars, path)194 if len(ops) == 1:195 # if there is only a single operation for a (path, method) combination,196 # the default Werkzeug rule can be used directly (this is the case for most rules)197 op = ops[0]198 rules.append(_StrictMethodRule(string=rule_string, method=method, endpoint=op.operation)) # type: ignore199 else:200 # if there is an ambiguity with only the (path, method) combination,201 # a custom rule - which can use additional request metadata - needs to be used202 rules.append(_RequestMatchingRule(string=rule_string, method=method, operations=ops))203 return Map(204 rules=rules,205 strict_slashes=False,206 merge_slashes=False,207 converters={"path": GreedyPathConverter},208 )209class RestServiceOperationRouter:210 """211 A router implementation which abstracts the (quite complex) routing of incoming HTTP requests to a specific212 operation within a "REST" service (rest-xml, rest-json).213 """214 _map: Map215 def __init__(self, service: ServiceModel):216 self._map = _create_service_map(service)217 def match(self, request: Request) -> Tuple[OperationModel, Mapping[str, Any]]:218 """219 Matches the given request to the operation it targets (or raises an exception if no operation matches).220 :param request: The request of which the targeting operation needs to be found221 :return: A tuple with the matched operation and the (already parsed) path params222 :raises: Werkzeug's NotFound exception in case the given request does not match any operation223 """224 # bind the map to get the actual matcher225 matcher: MapAdapter = self._map.bind(request.host)226 # perform the matching227 rule, args = matcher.match(get_raw_path(request), method=request.method, return_rule=True)228 # if the found rule is a _RequestMatchingRule, the multi rule matching needs to be invoked to perform the229 # fine-grained matching based on the whole request230 if isinstance(rule, _RequestMatchingRule):231 rule = rule.match_request(request)232 # post process the arg keys and values233 # - the path param keys need to be "un-sanitized", i.e. sanitized rule variable names need to be reverted234 # - the path param values might still be url-encoded235 args = {_post_process_arg_name(k): unquote(v) for k, v in args.items()}236 # extract the operation model from the rule237 operation: OperationModel = rule.endpoint...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

QA Innovation &#8211; Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

Best 23 Web Design Trends To Follow In 2023

Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

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