Skip to content

Commit

Permalink
Rewrite haie/amenagement urls access tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault committed Sep 12, 2024
1 parent 6ac14ac commit f5ed77c
Showing 1 changed file with 42 additions and 33 deletions.
75 changes: 42 additions & 33 deletions config/tests/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,58 @@ def site() -> Site:


COMMON_URLS = [
reverse("home"),
reverse("login"),
reverse("password_reset"),
reverse("contact_us"),
reverse("accessibility"),
reverse("stats"),
reverse("privacy"),
reverse("terms_of_service"),
reverse("legal_mentions"),
reverse("moulinette_home"),
reverse("moulinette_result"),
"home",
"login",
"password_reset",
"contact_us",
"accessibility",
"stats",
"privacy",
"terms_of_service",
"legal_mentions",
"moulinette_home",
"moulinette_result",
]

HAIE_URLS = []

AMENAGEMENT_URLS = [
"/avis",
reverse("zone_map"),
reverse("2150_debug"),
reverse("faq"),
reverse("news_feed"),
reverse("geometricians"),
reverse("parcels_export"),
reverse("map"),
# "/avis",
"zone_map",
"2150_debug",
"faq",
"news_feed",
"geometricians",
"parcels_export",
"map",
]


@pytest.mark.parametrize("url", COMMON_URLS + HAIE_URLS)
@override_settings(ENVERGO_HAIE_DOMAIN="testserver")
def test_haie_can_access_pages(client):
for url in HAIE_URLS + COMMON_URLS:
response = client.get(url)
assert response.status_code < 400, f"Failed for URL: {url}"
def test_haie_can_access_haie_pages(client, url):
url = reverse(url)
response = client.get(url)
assert response.status_code < 400, f"Failed for URL: {url}"

for url in AMENAGEMENT_URLS:
response = client.get(url)
assert response.status_code == 404, f"Failed for URL: {url}"

@pytest.mark.parametrize("url", AMENAGEMENT_URLS)
@override_settings(ENVERGO_HAIE_DOMAIN="testserver")
def test_haie_cannot_access_amenagement_pages(client, url):
url = reverse(url)
response = client.get(url)
assert response.status_code == 404, f"Failed for URL: {url}"


@pytest.mark.parametrize("url", COMMON_URLS + AMENAGEMENT_URLS)
def test_amenagement_can_access_amenagement_pages(client, url):
url = reverse(url)
response = client.get(url)
assert response.status_code < 400, f"Failed for URL: {url}"

def test_amenagement_can_access_pages(client):
for url in AMENAGEMENT_URLS + COMMON_URLS:
response = client.get(url)
assert response.status_code < 400, f"Failed for URL: {url}"

for url in HAIE_URLS:
response = client.get(url)
assert response.status_code == 404, f"Failed for URL: {url}"
@pytest.mark.parametrize("url", HAIE_URLS)
def test_amenagement_cannot_access_haie_pages(client, url):
url = reverse(url)
response = client.get(url)
assert response.status_code == 404, f"Failed for URL: {url}"

0 comments on commit f5ed77c

Please sign in to comment.