Skip to content

Commit

Permalink
Add test for Python to return 500 on unhandled error
Browse files Browse the repository at this point in the history
  • Loading branch information
paneidos committed Jun 12, 2024
1 parent 789b686 commit 969b7a5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/runtimes/python/python3/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ def hello(event, context):
"body": json.dumps(body),
"statusCode": 200,
}

def error(event, context):
raise Exception("This is an error")
9 changes: 9 additions & 0 deletions tests/runtimes/python/python3/python3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ describe("Python 3 tests", function desc() {
assert.deepEqual(json, expected)
})
})

it("should return a 500 on error", async () => {
const url = new URL("/dev/error", BASE_URL)
const response = await fetch(url)
const json = await response.json()

assert.equal(response.status, 500)
assert.equal(json.message, "Internal Server Error")
})
})
6 changes: 6 additions & 0 deletions tests/runtimes/python/python3/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ functions:
method: get
path: hello
handler: handler.hello
error:
events:
- http:
method: get
path: error
handler: handler.error

0 comments on commit 969b7a5

Please sign in to comment.