beer/tests/test_beer.py

37 lines
821 B
Python
Raw Permalink Normal View History

2020-02-24 23:20:20 +01:00
# pylint: disable=no-name-in-module, redefined-outer-name
""" Unit tests """
import pytest
from beer import beer
@pytest.fixture
def client():
""" create flask app """
beer.app.config['TESTING'] = True
with beer.app.test_client() as client:
yield client
def test_slash(client):
"""Test wiwth no param"""
response = client.get('/')
assert response.status_code == 200
assert b'<title>beer</title>' in response.data
def test_parameters(client):
"""Test wiwth no param"""
hours = '18'
minutes = '30'
response = client.get('/'+hours)
assert response.status_code == 200
assert b'<title>beer</title>' in response.data
response = client.get('/'+hours+'/'+minutes)
assert response.status_code == 200
assert b'<title>beer</title>' in response.data