def test_querySecretNotValidSecretId(): event = { "source": "aws.secretsmanager", "detail": { "requestParameters": { "secretId": "XXX" } } } when(SecretMngrHandler).getSecretValue(...).thenReturn( json.dumps({"secretString": "{\"clientId\":\"sdsdf\"}"})) when(AppSyncClient).subscribe(...).thenReturn({}) when(AppSyncClient).sendRequest(...).thenRaise(Exception) when(AppSyncClient).getApiKey(...).thenReturn("dsfsdf") response = handler(event, {}) assert response.get("statusCode") == 500
def test_unknownevent(): response = handler({"id": "123", "secret": "12355"}, {}) assert response.get("statusCode") == 404