-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_app.py
38 lines (31 loc) · 1.01 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
35
36
37
38
import pytest
from flask import json
from app import app
@pytest.fixture
def client():
app.config['TESTING'] = True
with app.test_client() as client:
yield client
def test_home_status_code(client):
response = client.get('/')
assert response.status_code == 200
def test_home_data(client):
response = client.get('/')
assert response.status_code == 200
assert b'<html>' in response.data
assert b'</html>' in response.data
def test_get_quote_status_code(client):
response = client.get('/api/random')
assert response.status_code == 200
def test_get_quote_data(client):
response = client.get('/api/random')
data = json.loads(response.get_data())
assert 'quote' in data
assert 'author' in data
def test_search_status_code(client):
response = client.get('/api/search/wealth')
assert response.status_code == 200
def test_search_data(client):
response = client.get('/api/search/wealth')
data = json.loads(response.get_data())
assert 'results' in data