whoogle-search/test/test_autocomplete.py
Ben Busby ba7409f230
Refactor app to use enum constants for endpoints
Simplifying routing a bit helps me to check which endpoint the user is
visiting. Also will make it a lot easier down the road to rewrite,
whenever I get around to renaming "autocomplete" to a more appropriate
name (like "suggestion" or something).
2021-11-16 18:46:37 -07:00

16 lines
477 B
Python

from app.models.endpoint import Endpoint
def test_autocomplete_get(client):
rv = client.get(f'/{Endpoint.autocomplete}?q=green+eggs+and')
assert rv._status_code == 200
assert len(rv.data) >= 1
assert b'green eggs and ham' in rv.data
def test_autocomplete_post(client):
rv = client.post(f'/{Endpoint.autocomplete}', data=dict(q='the+cat+in+the'))
assert rv._status_code == 200
assert len(rv.data) >= 1
assert b'the cat in the hat' in rv.data