def test_consumer_slave_lambda_handler(): load = loader_main(load=myload, rate=1, baseline=0, base_url='https://postman-echo.com', filters={}) from pprint import pprint pprint(load) event = { 'delay_per_req': 0.01, 'delay_random': True, 'load': load, 'rate': 1, 'app': 'pytest', 'identifier': 'qa', 'parent_lambda': 'pytest', 'child_lambda': 'sr-dev-consumer-slave', 'headers': { 'User-Agent': 'sr-dev-pytest' }, } event = json.dumps(event) event = zipper.compress(data=event) event = {'payload': event} num_reqs_val = consumer_slave.lambda_handler(event, '') assert num_reqs_val == 1
def test_consumer_slave_lambda_handler(): load = loader_main( load=myload, rate=1, baseline=0, base_url="https://postman-echo.com", filters={} ) from pprint import pprint pprint(load) event = { "delay_per_req": 0.01, "delay_random": True, "load": load, "rate": 1, "app": "pytest", "identifier": "qa", "parent_lambda": "pytest", "child_lambda": "sr-dev-consumer-slave", "headers": {"User-Agent": "sr-dev-pytest"}, } event = json.dumps(event) event = zipper.compress(data=event) event = {"payload": event} num_reqs_val = consumer_slave.lambda_handler(event, "") assert num_reqs_val == 1
def _invoke_func_w_zip(payload: dict, func: str): payload = json.dumps(payload) payload = zipper.compress( data=payload ) # Need to compress payload due to 130KB limit on Lambda invoke API payload = {"payload": payload} resp = _invoke_func(payload, func) return resp
def test_zipping_str(): data = 'asdf' zipped = zipper.compress(data=data) unzipped = zipper.decompress(data=zipped) assert unzipped == data
def test_zipping_dict(): orig_data = { 'test': 'asdasdasdasd', '1': 1, 'list': ['asdf'], 'bool': True } data = json.dumps(orig_data) zipped = zipper.compress(data=data) unzipped = zipper.decompress(data=zipped) unzipped = json.loads(unzipped) print(unzipped) print(orig_data) assert unzipped == orig_data
def test_zipping_dict(): orig_data = { "test": "asdasdasdasd", "1": 1, "list": ["asdf"], "bool": True } data = json.dumps(orig_data) zipped = zipper.compress(data=data) unzipped = zipper.decompress(data=zipped) unzipped = json.loads(unzipped) print(unzipped) print(orig_data) assert unzipped == orig_data