Fix tests following content move

This commit is contained in:
Ben Sturmfels 2024-05-10 11:39:41 +10:00
parent 2ff551147c
commit 1792c7ed8b
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0

View file

@ -3,7 +3,7 @@ import datetime
from django.conf import settings from django.conf import settings
from django.http import Http404 from django.http import Http404
import pytest import pytest
from pytest_django.asserts import assertContains, assertTemplateUsed from pytest_django.asserts import assertContains
from . import views from . import views
from conservancy.fundgoal.models import FundraisingGoal from conservancy.fundgoal.models import FundraisingGoal
@ -24,20 +24,19 @@ def create_fundraising_goal():
def test_about_page_served(rf): def test_about_page_served(rf):
create_fundraising_goal() create_fundraising_goal()
request = rf.get('/about/') request = rf.get('/about/')
with assertTemplateUsed('about/index.html'): response = views.content(request)
response = views.index(request).render()
assertContains(response, 'Conservancy is a nonprofit organization') assertContains(response, 'Conservancy is a nonprofit organization')
def test_annual_report_file_served(rf): def test_annual_report_file_served(rf):
request = rf.get('/docs/conservancy_annual-report_fy-2011.pdf') request = rf.get('/projects/apply/ConservancyFSATemplate.pdf')
response = views.index(request) response = views.content(request)
assert response.headers['Content-Type'] == 'application/pdf' assert response.headers['Content-Type'] == 'application/pdf'
def test_path_traversal_404s(rf): def test_path_traversal_404s(rf):
# Will work in development only # Will work in development only
assert (settings.BASE_DIR / 'static' / 'about/../../../conservancy-website.sqlite3').exists() assert (settings.BASE_DIR / 'content' / 'about/../../../conservancy-website.sqlite3').exists()
request = rf.get('/about/../../../conservancy-website.sqlite3') request = rf.get('/about/../../../conservancy-website.sqlite3')
with pytest.raises(Http404): with pytest.raises(Http404):
views.index(request) views.content(request)