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.http import Http404
import pytest
from pytest_django.asserts import assertContains, assertTemplateUsed
from pytest_django.asserts import assertContains
from . import views
from conservancy.fundgoal.models import FundraisingGoal
@ -24,20 +24,19 @@ def create_fundraising_goal():
def test_about_page_served(rf):
create_fundraising_goal()
request = rf.get('/about/')
with assertTemplateUsed('about/index.html'):
response = views.index(request).render()
response = views.content(request)
assertContains(response, 'Conservancy is a nonprofit organization')
def test_annual_report_file_served(rf):
request = rf.get('/docs/conservancy_annual-report_fy-2011.pdf')
response = views.index(request)
request = rf.get('/projects/apply/ConservancyFSATemplate.pdf')
response = views.content(request)
assert response.headers['Content-Type'] == 'application/pdf'
def test_path_traversal_404s(rf):
# 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')
with pytest.raises(Http404):
views.index(request)
views.content(request)