File tree Expand file tree Collapse file tree 4 files changed +24
-8
lines changed
Expand file tree Collapse file tree 4 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ def hello_world():
2020
2121 return '<h1>Hello World!</h1>'
2222
23- @application .route ('/<name>' )
23+ @application .route ('/greeting/ <name>' )
2424def personal_greeting (name ):
2525 """
2626 Prints a personalized greeting.
Original file line number Diff line number Diff line change @@ -40,19 +40,35 @@ def test_hello_world(self):
4040 message = response .get_data (as_text = True )
4141 assert message == "<h1>Hello World!</h1>"
4242
43- def test_personal_greeting (self ):
43+ def test_personal_greeting_name_provided (self ):
4444 """
45- Test case on endpoint `/<name>`.
45+ Test case on endpoint `/greeting/ <name>`.
4646 """
4747
4848 name = "Lulu"
4949
50- response = self .client .get (f'/{ name } ' )
50+ response = self .client .get (f'/greeting/ { name } ' )
5151 assert response .status_code == 200
5252
5353 message = response .get_data (as_text = True )
5454 assert message == f"Hello, { name } !"
55+
56+ def test_personal_greeting_no_name_provided (self ):
57+ """
58+ Test case on endpoint `/greeting` (no name provided).
59+ """
60+
61+ response = self .client .get ('/greeting' )
62+ assert response .status_code == 404
5563
64+ def test_personal_greeting_url_no_keyword (self ):
65+ """
66+ Test case on endpoint `/{name}` (`/greeting` is missing in URL).
67+ """
68+
69+ response = self .client .get ('/lulu' )
70+ assert response .status_code == 404
71+
5672 def test_healthcheck_getrequest (self ):
5773 """
5874 Test case on a GET request to endpoint `/healthcheck`.
Original file line number Diff line number Diff line change @@ -34,11 +34,11 @@ paths:
3434 schema :
3535 type : string
3636 example : <h1>Hello World!</h1>
37- /{name} :
37+ /greeting/ {name} :
3838 get :
3939 tags :
4040 - " SimpleText"
41- description : Prints a personalized greeting with the name provided by < name> .
41+ description : Prints a personalized greeting with the name provided by `{ name}` .
4242 parameters :
4343 - name : name
4444 in : path
Original file line number Diff line number Diff line change @@ -34,11 +34,11 @@ paths:
3434 schema :
3535 type : string
3636 example : <h1>Hello World!</h1>
37- /{name} :
37+ /greeting/ {name} :
3838 get :
3939 tags :
4040 - " SimpleText"
41- description : Prints a personalized greeting with the name provided by < name> .
41+ description : Prints a personalized greeting with the name provided by `{ name}` .
4242 parameters :
4343 - name : name
4444 in : path
You can’t perform that action at this time.
0 commit comments