def test_missing_as_path(): setup_parameters() event = get_event() event['ResourceProperties'] = {'ParameterPaths': ['/no/such/path']} response = index.lambda_handler(event) assert response['Status'] == 'SUCCESS' assert response['Data'] == {}
def test_success_all(): setup_parameters() event = get_event() response = index.lambda_handler(event) data = response['Data'] assert response['Status'] == 'SUCCESS' assert response['StackId'] == event['StackId'] assert response['LogicalResourceId'] == event['LogicalResourceId'] assert len(response['PhysicalResourceId']) > 0 assert response['RequestId'] == event['RequestId'] for i in [params, params_as_path]: for k, v in i.items(): assert param_is_expected(data[k], v) for k in event['ResourceProperties']['ParameterPathsAsList']: expected = [ y[0] if y[1] != 'StringList' else [z.strip() for z in y[0].split(',')] for x, y in params_as_list.items() if x.startswith(k) ] assert len(expected) == len(data[k]) for v in expected: assert v in data[k]
def test_delete(): setup_parameters() event = get_event() event['RequestType'] = 'Delete' response = index.lambda_handler(event) assert response['Status'] == 'SUCCESS' assert response['StackId'] == event['StackId'] assert response['LogicalResourceId'] == event['LogicalResourceId'] assert response['RequestId'] == event['RequestId']
def test_empty_params(): setup_parameters() event = get_event() del event['ResourceProperties'] response = index.lambda_handler(event) assert 'Status' in response assert response['Status'] == 'FAILED' assert response['StackId'] == event['StackId'] assert response['LogicalResourceId'] == event['LogicalResourceId'] assert response['RequestId'] == event['RequestId'] assert response['Reason'] == index.MSG_EMPTY_PROPS