Skip to content

Commit 422f193

Browse files
committed
Change endpoint URL of personalized greetin (/{name} -> /greeting/{name}).
1 parent 3983efb commit 422f193

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

App.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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>')
2424
def personal_greeting(name):
2525
"""
2626
Prints a personalized greeting.

__tests__/test_App.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff 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`.

api/doc/swagger.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

docs/swagger.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)