afpy.org/tests.py

35 lines
952 B
Python
Raw Normal View History

2017-09-22 09:30:21 +00:00
import pytest
2021-07-02 07:21:36 +00:00
from afpy import application
2017-09-22 09:30:21 +00:00
2017-09-22 14:22:25 +00:00
def test_home():
2021-07-02 07:21:36 +00:00
response = application.test_client().get("/")
2017-09-22 09:30:21 +00:00
assert response.status_code == 200
@pytest.mark.parametrize("name", ["", "communaute"])
2017-09-22 14:22:25 +00:00
def test_html(name):
2021-07-02 07:21:36 +00:00
response = application.test_client().get(f"/{name}")
2017-09-22 09:30:21 +00:00
assert response.status_code == 200
@pytest.mark.parametrize("name", ["charte", "a-propos"])
2017-09-22 14:22:25 +00:00
def test_rest(name):
2021-07-02 07:21:36 +00:00
response = application.test_client().get(f"/docs/{name}")
2017-09-22 14:22:25 +00:00
assert response.status_code == 200
2017-09-22 09:30:21 +00:00
def test_404():
2021-07-02 07:21:36 +00:00
response = application.test_client().get("/unknown")
2017-09-22 09:30:21 +00:00
assert response.status_code == 404
2021-07-02 07:21:36 +00:00
response = application.test_client().get("/docs/unknown")
2017-09-22 14:22:25 +00:00
assert response.status_code == 404
2021-07-02 07:21:36 +00:00
response = application.test_client().get("/feed/unknown")
2017-09-22 14:22:25 +00:00
assert response.status_code == 404
2018-10-05 14:50:17 +00:00
def test_read_posts():
2021-07-02 07:21:36 +00:00
response = application.test_client().get("/actualites/page/1")
2018-10-05 14:50:17 +00:00
assert response.status_code == 200