How to use get_rest_apis method in localstack

Best Python code snippet using localstack_python

test_apigw_rest_api.py

Source:test_apigw_rest_api.py Github

copy

Full Screen

...43 @patch.object(apigw_rest_api, 'boto3')44 def test_boto3_client_properly_instantiated(self, mock_boto):45 ApiGwRestApi(self.module)46 mock_boto.client.assert_called_once_with('apigateway')47 def test_process_request_calls_boto3_get_rest_apis(self):48 self.restapi.module.params = { 'name': 'whatever' }49 self.restapi.process_request()50 self.restapi.client.get_rest_apis.assert_called_once_with()51 def test_process_request_fails_when_get_rest_apis_returns_error(self):52 self.restapi.module.params = { 'name': 'whatever' }53 self.restapi.client.get_rest_apis = mock.MagicMock(side_effect=BotoCoreError())54 self.restapi.process_request()55 self.restapi.module.fail_json.assert_called_once_with(56 msg='Encountered fatal error calling boto3 get_rest_apis function: An unspecified error occurred')57 def test_process_request_exits_with_no_change_when_removing_non_existent_api(self):58 self.restapi.module.params = { 'name': 'whatever', 'state': 'absent' }59 self.restapi.client.get_rest_apis = mock.MagicMock(return_value={'items': []})60 self.restapi.process_request()61 self.restapi.module.exit_json.assert_called_once_with(changed=False, api=None)...

Full Screen

Full Screen

test_multiregion.py

Source:test_multiregion.py Github

copy

Full Screen

...50 gw_1 = aws_stack.create_external_boto_client("apigateway", region_name=REGION1)51 gw_2 = aws_stack.create_external_boto_client("apigateway", region_name=REGION2)52 gw_3 = aws_stack.create_external_boto_client("apigateway", region_name=REGION3)53 sqs_1 = aws_stack.create_external_boto_client("sqs", region_name=REGION1)54 len_1 = len(gw_1.get_rest_apis()["items"])55 len_2 = len(gw_2.get_rest_apis()["items"])56 api_name1 = "a-%s" % short_uid()57 gw_1.create_rest_api(name=api_name1)58 result1 = gw_1.get_rest_apis()["items"]59 self.assertEqual(len(result1), len_1 + 1)60 self.assertEqual(len(gw_2.get_rest_apis()["items"]), len_2)61 api_name2 = "a-%s" % short_uid()62 gw_2.create_rest_api(name=api_name2)63 result2 = gw_2.get_rest_apis()["items"]64 self.assertEqual(len(gw_1.get_rest_apis()["items"]), len_1 + 1)65 self.assertEqual(len(result2), len_2 + 1)66 api_name3 = "a-%s" % short_uid()67 queue_name1 = "q-%s" % short_uid()68 result = sqs_1.create_queue(QueueName=queue_name1)69 queue_arn = aws_stack.sqs_queue_arn(queue_name1, region_name=REGION1)70 result = connect_api_gateway_to_sqs(71 api_name3, stage_name="test", queue_arn=queue_arn, path="/data", region_name=REGION372 )73 api_id = result["id"]74 result = gw_3.get_rest_apis()["items"]75 self.assertEqual(result[-1]["name"], api_name3)76 # post message and receive from SQS77 url = self._gateway_request_url(api_id=api_id, stage_name="test", path="/data")78 test_data = {"foo": "bar"}79 result = requests.post(url, data=json.dumps(test_data))80 self.assertEqual(result.status_code, 200)81 messages = aws_stack.sqs_receive_message(queue_arn)["Messages"]82 self.assertEqual(len(messages), 1)83 self.assertEqual(84 json.loads(to_str(base64.b64decode(to_str(messages[0]["Body"])))), test_data85 )86 def _gateway_request_url(self, api_id, stage_name, path):87 pattern = "%s/restapis/{api_id}/{stage_name}/%s{path}" % (88 config.service_url("apigateway"),...

Full Screen

Full Screen

api_gateway.py

Source:api_gateway.py Github

copy

Full Screen

...12 description='Api for Revizor Tests',13 endpointConfiguration={14 'types': ['EDGE', ]15 })['id']16 assert any([api for api in client.get_rest_apis()['items'] if api['name'] == api_name])17 assert client.get_rest_api(restApiId=api_id)['name'] == api_name18 client.delete_rest_api(restApiId=api_id)19 with world.assert_raises(boto_exceptions.ClientError, 'NotFound'):20 client.get_rest_api(restApiId=api_id)21 def verify_denied(self, error_text):22 client = self.platform.get_client('apigateway')23 with world.assert_raises(boto_exceptions.ClientError, error_text):24 client.get_rest_apis()25 def verify_policy(self, prefix=False, pattern=False):26 client = self.platform.get_client('apigateway')27 if prefix:28 api_name = self.platform.get_test_name('api_')29 with world.assert_raises(boto_exceptions.ClientError,30 "Action 'CreateRestApi' violates policy 'csg.resource.name.prefix'"):31 client.create_rest_api(name=api_name,32 description='Api for Revizor Tests',33 endpointConfiguration={34 'types': ['EDGE', ]35 })36 if pattern:37 api_name = 'tmp_%s' % self.platform.get_test_name('api')38 with world.assert_raises(boto_exceptions.ClientError,39 "Action 'CreateRestApi' violates policy 'csg.resource.name.validation_pattern'"):40 client.create_rest_api(name=api_name,41 description='Api for Revizor Tests',42 endpointConfiguration={43 'types': ['EDGE', ]44 })45 api_name = 'tmp_%s' % self.platform.get_test_name('api_')46 api_id = client.create_rest_api(name=api_name,47 description='Api for Revizor Tests',48 endpointConfiguration={49 'types': ['EDGE', ]50 })['id']51 assert any([api for api in client.get_rest_apis()['items'] if api['name'] == api_name])...

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