Best Python code snippet using localstack_python
test_s3.py
Source:test_s3.py
...1131 response = requests.put(presign_url, data=OBJECT_DATA)1132 self.assertEqual(response.status_code, 403)1133 client.delete_object(Bucket=BUCKET, Key=OBJECT_KEY)1134 client.delete_bucket(Bucket=BUCKET)1135 def test_precondition_failed_error(self):1136 bucket = 'bucket-%s' % short_uid()1137 client = self._get_test_client()1138 client.create_bucket(Bucket=bucket)1139 client.put_object(Bucket=bucket, Key='foo', Body=b'{"foo": "bar"}')1140 # this line makes localstack crash:1141 try:1142 client.get_object(Bucket=bucket, Key='foo', IfMatch='"not good etag"')1143 except ClientError as e:1144 self.assertEqual(e.response['Error']['Code'], 'PreconditionFailed')1145 self.assertEqual(e.response['Error']['Message'], 'At least one of the pre-conditions you '1146 'specified did not hold')1147 client.delete_object(Bucket=bucket, Key='foo')1148 client.delete_bucket(Bucket=bucket)1149 def test_cors_configurtaions(self):...
tests_sync.py
Source:tests_sync.py
...47 response = get_response(mock_client, {})48 self.assertEqual(response, 'success')49 @mock.patch('openprocurement_client.clients.APIResourceClientSync.'50 'sync_resource_items')51 def test_precondition_failed_error(self, mock_sync_resource_items):52 mock_sync_resource_items.side_effect = [PreconditionFailed(),53 'success']54 mock_client = TestAPIResourceClientSync()55 response = get_response(mock_client, {})56 log_strings = self.log_capture_string.getvalue().split('\n')57 self.assertEqual(log_strings[0],58 'PreconditionFailed: Not described error yet.')59 self.assertEqual(response, 'success')60 @mock.patch('openprocurement_client.clients.APIResourceClientSync.'61 'sync_resource_items')62 def test_connection_error(self, mock_sync_resource_items):63 error = ConnectionError('connection error')64 mock_sync_resource_items.side_effect = [error, error, 'success']65 mock_client = TestAPIResourceClientSync()...
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!!