Skip to content

Commit 1ad3386

Browse files
author
Ace Nassri
committed
Add missing data case to tests
Change-Id: Ieb4ef73ac5a675908904ffccac902daff69551c1
1 parent 636617d commit 1ad3386

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

functions/helloworld/main_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ def test_hello_http_args(app):
4242
assert 'Hello, test!' in res
4343

4444

45+
def test_hello_http_empty_json(app):
46+
with app.test_request_context(json=''):
47+
res = main.hello_http(flask.request)
48+
assert 'Hello, World!' in res
49+
50+
4551
def test_hello_http_xss(app):
4652
with app.test_request_context(json={'name': '<script>alert(1)</script>'}):
4753
res = main.hello_http(flask.request)
@@ -54,6 +60,14 @@ def test_hello_content_json(app):
5460
assert 'Hello, test!' in res
5561

5662

63+
def test_hello_content_empty_json(app):
64+
with app.test_request_context(json=''):
65+
with pytest.raises(
66+
ValueError,
67+
message="JSON is invalid, or missing a 'name' property"):
68+
main.hello_content(flask.request)
69+
70+
5771
def test_hello_content_urlencoded(app):
5872
with app.test_request_context(
5973
data={'name': 'test'},

0 commit comments

Comments
 (0)