Code source de oc_lettings_site.tests

 1import pytest
 2
 3from django.urls import reverse, resolve
 4from django.test import Client
 5from pytest_django.asserts import assertTemplateUsed
 6
 7
[docs] 8@pytest.mark.django_db 9def test_profiles_index_url(): 10 """ 11 Test that the URL for the 'index' view resolves 12 to the correct view function. 13 """ 14 path = reverse("index") 15 16 assert path == "/" 17 assert resolve(path).view_name == "index"
18 19
[docs] 20@pytest.mark.django_db 21def test_trigger_error_url_resolves(): 22 """ 23 Test that the URL for the 'sentrytest' view resolves 24 to the correct view function. 25 """ 26 path = reverse("sentrytest") 27 28 assert path == "/sentry-debug/" 29 assert resolve(path).view_name == "sentrytest"
30 31
[docs] 32@pytest.mark.django_db 33def test_index_view(): 34 """ 35 Test that the 'index' view returns a status code of 200 36 and uses the correct template. 37 38 """ 39 client = Client() 40 path = reverse("index") 41 42 response = client.get(path) 43 44 assert response.status_code == 200 45 assertTemplateUsed(response, "oc_lettings_site/index.html")
46 47
[docs] 48@pytest.mark.django_db 49def test_trigger_error_view(): 50 """ 51 Test that the 'sentrytest' view returns a status code of 500 52 and uses the 'error.html' template. 53 """ 54 client = Client() 55 path = reverse("sentrytest") 56 57 response = client.get(path) 58 59 assert response.status_code == 500 60 assertTemplateUsed(response, 'error.html')
61 62
[docs] 63def test_dummy(): 64 assert 1