-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_app.py
34 lines (28 loc) · 1.05 KB
/
test_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pytest
from app import app
@pytest.fixture
def client():
app.config['TESTING'] = True
with app.test_client() as client:
yield client
def test_index_page(client):
response = client.get('/')
assert response.status_code == 200
assert b"Create an Item" in response.data
def test_create_item(client):
response = client.post('/create', data={'name': 'Test Item', 'description': 'This is a test'})
assert response.status_code == 200
assert b"Item Created Successfully!" in response.data
def test_items_page(client):
response = client.get('/items')
assert response.status_code == 200
assert b"Items" in response.data
def test_items_page_with_items(client):
client.post('/create', data={'name': 'Test Item', 'description': 'This is a test'})
response = client.get('/items')
assert response.status_code == 200
assert b"Test Item" in response.data
assert b"This is a test" in response.data
def test_invalid_route(client):
response = client.get('/invalid')
assert response.status_code == 404