Skip to content

Commit 951f142

Browse files
Add basic endpoints for app
1 parent 1047989 commit 951f142

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

app.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from flask import Flask
2+
3+
app = Flask(__name__)
4+
5+
6+
@app.route('/')
7+
def home():
8+
return "<h1>Hello world!</h1>"
9+
10+
11+
@app.route('/<name>')
12+
def name(name):
13+
return "<h1>Hello {}!</h1>".format(name)
14+
15+
16+
if __name__ == "__main__":
17+
app.run(debug=True)

tests.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import pytest
2+
3+
4+
@pytest.mark.usefixtures('client_class')
5+
class TestCore:
6+
7+
@pytest.fixture
8+
def app(self):
9+
from app import app
10+
return app
11+
12+
def test_get_home(self):
13+
response = self.client.get("/")
14+
assert response.data.decode('utf-8') == '<h1>Hello world!</h1>'
15+
assert response.status_code == 200
16+
17+
def test_get_name(self):
18+
response = self.client.get("/Rafael")
19+
assert response.data.decode('utf-8') == '<h1>Hello Rafael!</h1>'
20+
assert response.status_code == 200

0 commit comments

Comments
 (0)