Best Python code snippet using localstack_python
test_error_injection.py
Source:test_error_injection.py
...25 test_all_errors = kinesis.put_records(StreamName=TEST_STREAM_NAME, Records=records)26 assert_equal(test_all_errors['FailedRecordCount'], 1)27 # reset probability to zero28 config.KINESIS_ERROR_PROBABILITY = 0.029def test_dynamodb_error_injection():30 dynamodb = aws_stack.connect_to_resource('dynamodb')31 # create table with stream forwarding config32 testutil.create_dynamodb_table(TEST_TABLE_NAME, partition_key=PARTITION_KEY)33 table = dynamodb.Table(TEST_TABLE_NAME)34 # by default, no errors35 test_no_errors = table.put_item(Item={PARTITION_KEY: short_uid(), 'data': 'foobar123'})36 assert_equal(test_no_errors['ResponseMetadata']['HTTPStatusCode'], 200)37 # with a probability of 1, always throw errors38 config.DYNAMODB_ERROR_PROBABILITY = 1.039 assert_raises(ClientError, table.put_item, Item={PARTITION_KEY: short_uid(), 'data': 'foobar123'})40 # reset probability to zero...
34119_test_error_injection.py
Source:34119_test_error_injection.py
...25 test_all_errors = kinesis.put_records(StreamName=TEST_STREAM_NAME, Records=records)26 assert_equal(test_all_errors['FailedRecordCount'], 1)27 # reset probability to zero28 config.KINESIS_ERROR_PROBABILITY = 0.029def test_dynamodb_error_injection():30 dynamodb = aws_stack.connect_to_resource('dynamodb')31 # create table with stream forwarding config32 testutil.create_dynamodb_table(TEST_TABLE_NAME, partition_key=PARTITION_KEY)33 table = dynamodb.Table(TEST_TABLE_NAME)34 # by default, no errors35 test_no_errors = table.put_item(Item={PARTITION_KEY: short_uid(), 'data': 'foobar123'})36 assert_equal(test_no_errors['ResponseMetadata']['HTTPStatusCode'], 200)37 # with a probability of 1, always throw errors38 config.DYNAMODB_ERROR_PROBABILITY = 1.039 assert_raises(ClientError, table.put_item, Item={PARTITION_KEY: short_uid(), 'data': 'foobar123'})40 # reset probability to zero...
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!!