How to use apply_request_parameters method in localstack

Best Python code snippet using localstack_python

test_apigateway.py

Source:test_apigateway.py Github

copy

Full Screen

...79 self.assertEqual(None, result)80 path_args = {"/foo/{param1}/baz": {}, "/foo/{param1}/{param2}": {}}81 path, result = get_resource_for_path("/foo/bar/baz", path_args)82 self.assertEqual("/foo/{param1}/baz", path)83 def test_apply_request_parameters(self):84 integration = {85 "type": "HTTP_PROXY",86 "httpMethod": "ANY",87 "uri": "https://httpbin.org/anything/{proxy}",88 "requestParameters": {"integration.request.path.proxy": "method.request.path.proxy"},89 "passthroughBehavior": "WHEN_NO_MATCH",90 "timeoutInMillis": 29000,91 "cacheNamespace": "041fa782",92 "cacheKeyParameters": [],93 }94 uri = apply_request_parameters(95 uri="https://httpbin.org/anything/{proxy}",96 integration=integration,97 path_params={"proxy": "foo/bar/baz"},98 query_params={"param": "foobar"},99 )100 self.assertEqual("https://httpbin.org/anything/foo/bar/baz?param=foobar", uri)101 def test_if_request_is_valid_with_no_resource_methods(self):102 ctx = ApiInvocationContext("POST", "/", b"", {})103 validator = RequestValidator(ctx, None)104 self.assertTrue(validator.is_request_valid())105 def test_if_request_is_valid_with_no_matching_method(self):106 ctx = ApiInvocationContext("POST", "/", b"", {})107 ctx.resource = {"resourceMethods": {"GET": {}}}108 validator = RequestValidator(ctx, None)...

Full Screen

Full Screen

g_variants.py

Source:g_variants.py Github

copy

Full Screen

...63 value=[value[1]],64 operator=Operator.LESS_EQUAL65 ))66 return filters67def apply_request_parameters(query: Dict[str, List[dict]], qparams: RequestParams):68 LOG.debug("Request parameters len = {}".format(len(qparams.query.request_parameters)))69 if len(qparams.query.request_parameters) > 0 and "$and" not in query:70 query["$and"] = []71 for k, v in qparams.query.request_parameters.items():72 if k == "start":73 if isinstance(v, str):74 v = v.split(',')75 filters = generate_position_filter_start(k, v)76 for filter in filters:77 query["$and"].append(apply_alphanumeric_filter({}, filter))78 elif k == "end":79 if isinstance(v, str):80 v = v.split(',')81 filters = generate_position_filter_end(k, v)82 for filter in filters:83 query["$and"].append(apply_alphanumeric_filter({}, filter))84 elif k == "variantMinLength" or k == "variantMaxLength" or k == "mateName":85 continue86 else:87 query["$and"].append(apply_alphanumeric_filter({}, AlphanumericFilter(88 id=VARIANTS_PROPERTY_MAP[k],89 value=v90 )))91 return query92def get_variants(entry_id: Optional[str], qparams: RequestParams):93 query = apply_request_parameters({}, qparams)94 query = apply_filters(query, qparams.query.filters)95 schema = DefaultSchemas.GENOMICVARIATIONS96 count = get_count(client.beacon.genomicVariations, query)97 docs = get_documents(98 client.beacon.genomicVariations,99 query,100 qparams.query.pagination.skip,101 qparams.query.pagination.limit102 )103 return schema, count, docs104def get_variant_with_id(entry_id: Optional[str], qparams: RequestParams):105 query = {"$and": [{"variantInternalId": entry_id}]}106 query = apply_request_parameters(query, qparams)107 query = apply_filters(query, qparams.query.filters)108 schema = DefaultSchemas.GENOMICVARIATIONS109 count = get_count(client.beacon.genomicVariations, query)110 docs = get_documents(111 client.beacon.genomicVariations,112 query,113 qparams.query.pagination.skip,114 qparams.query.pagination.limit115 )116 return schema, count, docs117def get_biosamples_of_variant(entry_id: Optional[str], qparams: RequestParams):118 query = {"$and": [{"variantInternalId": entry_id}]}119 query = apply_request_parameters(query, qparams)120 query = apply_filters(query, qparams.query.filters)121 biosample_ids = client.beacon.genomicVariations \122 .find_one(query, {"caseLevelData.biosamplesId": 1, "_id": 0})123 biosample_ids = [ r for r in biosample_ids ] if biosample_ids else []124 query = apply_request_parameters({}, qparams)125 query = query_ids(query, biosample_ids)126 query = apply_filters(query, qparams.query.filters)127 schema = DefaultSchemas.BIOSAMPLES128 count = get_count(client.beacon.biosamples, query)129 docs = get_documents(130 client.beacon.biosamples,131 query,132 qparams.query.pagination.skip,133 qparams.query.pagination.limit134 )135 return schema, count, docs136def get_individuals_of_variant(entry_id: Optional[str], qparams: RequestParams):137 query = {"$and": [{"variantInternalId": entry_id}]}138 query = apply_request_parameters(query, qparams)139 query = apply_filters(query, qparams.query.filters)140 individual_ids = client.beacon.genomicVariations \141 .find(query)142 individual_ids = [ r["caseLevelData"]["individualId"] for r in individual_ids] if individual_ids else []143 query = apply_request_parameters({}, qparams)144 query = query_ids(query, individual_ids)145 query = apply_filters(query, qparams.query.filters)146 schema = DefaultSchemas.INDIVIDUALS147 count = get_count(client.beacon.individuals, query)148 docs = get_documents(149 client.beacon.individuals,150 query,151 qparams.query.pagination.skip,152 qparams.query.pagination.limit153 )154 return schema, count, docs155def get_runs_of_variant(entry_id: Optional[str], qparams: RequestParams):156 query = {"$and": [{"variantInternalId": entry_id}]}157 query = apply_request_parameters(query, qparams)158 query = apply_filters(query, qparams.query.filters)159 run_ids = client.beacon.genomicVariations \160 .find_one(query, {"caseLevelData.runId": 1, "_id": 0})161 run_ids = [ r for r in run_ids] if run_ids else []162 query = apply_request_parameters({}, qparams)163 query = query_ids(query, run_ids)164 query = apply_filters(query, qparams.query.filters)165 schema = DefaultSchemas.RUNS166 count = get_count(client.beacon.runs, query)167 docs = get_documents(168 client.beacon.runs,169 query,170 qparams.query.pagination.skip,171 qparams.query.pagination.limit172 )173 return schema, count, docs174def get_analyses_of_variant(entry_id: Optional[str], qparams: RequestParams):175 query = {"$and": [{"variantInternalId": entry_id}]}176 query = apply_request_parameters(query, qparams)177 query = apply_filters(query, qparams.query.filters)178 analysis_ids = client.beacon.genomicVariations \179 .find_one(query, {"caseLevelData.analysisId": 1, "_id": 0})180 analysis_ids = [r for r in analysis_ids] if analysis_ids else []181 query = apply_request_parameters({}, qparams)182 query = query_ids(query, analysis_ids)183 query = apply_filters(query, qparams.query.filters)184 schema = DefaultSchemas.ANALYSES185 count = get_count(client.beacon.analyses, query)186 docs = get_documents(187 client.beacon.analyses,188 query,189 qparams.query.pagination.skip,190 qparams.query.pagination.limit191 )...

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