Skip to content

Commit 82b51a5

Browse files
author
Rio Goodman
committed
use env var to maintain state, test for client error
1 parent 2376f91 commit 82b51a5

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

localstack/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
TEST_APIGATEWAY_URL = 'http://%s:%s' % (LOCALHOST, DEFAULT_PORT_APIGATEWAY)
4343

4444
# For testing
45-
KINESIS_RETURN_ERRORS = False
45+
if 'KINESIS_RETURN_ERRORS' not in os.environ:
46+
os.environ['KINESIS_RETURN_ERRORS'] = 'False'
4647

4748
# AWS user account ID used for tests
4849
TEST_AWS_ACCOUNT_ID = '123456789'

localstack/mock/infra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def update_apigateway(method, path, data, headers, response=None, return_forward
368368

369369
def update_kinesis(method, path, data, headers, response=None, return_forward_info=False):
370370
if return_forward_info:
371-
if KINESIS_RETURN_ERRORS:
371+
if os.environ['KINESIS_RETURN_ERRORS'] == 'True':
372372
return 500
373373
else:
374374
return True

tests/test_kin.py renamed to tests/test_kinesis_errors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import __init__
22
import boto3
3+
from nose.tools import assert_raises
4+
from botocore.exceptions import ClientError
35
from localstack.constants import *
46
from localstack.utils.common import *
57
from localstack.mock import infra
@@ -26,9 +28,9 @@ def start_test(env=ENV_DEV):
2628
}
2729
]
2830

29-
KINESIS_RETURN_ERRORS = True
30-
kinesis.put_records(StreamName='test-stream-1', Records=records)
31-
KINESIS_RETURN_ERRORS = False
31+
os.environ['KINESIS_RETURN_ERRORS'] = 'True'
32+
assert_raises(ClientError, kinesis.put_records, StreamName='test-stream-1', Records=records)
33+
os.environ['KINESIS_RETURN_ERRORS'] = 'False'
3234

3335
except KeyboardInterrupt, e:
3436
infra.KILLED = True

0 commit comments

Comments
 (0)