Newer
Older
"""
Check setup page at /setup URL.
MemeGenerator
Ruizhe Deng rxd@umich.edu
"""
import re
import bs4
def test_layout(client):
response = client.get("http://localhost:8000/setup?url=https%3A%2F%2Flive.staticflickr.com%2F3606%2F3369014165_7441c25d45_q.jpg")
assert response.status_code == 200
soup = bs4.BeautifulSoup(response.data, "html.parser")
inputs_in_form = [x for x in soup.find_all("input")]
types = [x.get("type") for x in soup.find_all("input")]
actions = [x.get("action") for x in soup.find_all("form")]
# check if there are four inputs in the page
assert len(inputs_in_form) == 4
# check if there is a submit button
types = [x.get("type") for x in soup.find_all("input")]
assert 'submit' in types
# check two text input
assert set(['text', 'text']).issubset(types)
# check if there's a link to generate page
assert '/generate' in actions