Add (very) basic tests for "pages" view + fix bad URL
This commit is contained in:
parent
d85fe3dff9
commit
fedc3f9a04
|
@ -3,5 +3,5 @@
|
|||
{% block main %}
|
||||
<h1>Page Not Found</h1>
|
||||
<p>What you were looking for is just not there.
|
||||
<p><a href="{{ url_for('index') }}">go somewhere nice</a>
|
||||
<p><a href="{{ url_for('pages') }}">go somewhere nice</a>
|
||||
{% endblock main %}
|
||||
|
|
38
tests/test_views.py
Normal file
38
tests/test_views.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
from functools import partial
|
||||
|
||||
import pytest
|
||||
from flask import url_for
|
||||
|
||||
import afpy
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def app():
|
||||
return afpy.app
|
||||
|
||||
|
||||
class TestPagesView:
|
||||
get_test_url = partial(url_for, 'pages')
|
||||
|
||||
def test_no_arguments(self, client):
|
||||
response = client.get(self.get_test_url())
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'template_name',
|
||||
[
|
||||
'a-propos',
|
||||
'feed',
|
||||
'rst',
|
||||
]
|
||||
)
|
||||
def test_with_arguments(self, client, template_name):
|
||||
response = client.get(self.get_test_url(template_name=template_name))
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
def test_404(self, client):
|
||||
response = client.get(self.get_test_url(template_name="bad_template_name_my_friend"))
|
||||
|
||||
assert response.status_code == 404
|
Loading…
Reference in New Issue
Block a user