Changeset - cba71044a243
[Not reviewed]
0 1 0
Ben Sturmfels (bsturmfels) - 2 months ago 2024-03-13 03:45:36
ben@sturm.com.au
Prevent test giving false-negative if settings.py moved
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conservancy/tests.py
Show inline comments
 
import datetime
 

	
 
from django.conf import settings
 
from django.http import Http404
 
import pytest
 
from pytest_django.asserts import assertContains, assertTemplateUsed
 

	
 
from . import views
 
from conservancy.fundgoal.models import FundraisingGoal
 

	
 

	
 
def create_fundraising_goal():
 
    FundraisingGoal.objects.create(
 
        fundraiser_code_name='cy2023-end-year-match',
 
        fundraiser_goal_amount=0,
...
 
@@ -26,15 +27,16 @@ def test_about_page_served(rf):
 
    with assertTemplateUsed('about/index.html'):
 
        response = views.index(request).render()
 
    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)
 
    assert response.headers['Content-Type'] == 'application/pdf'
 

	
 

	
 
def test_path_traversal_404s(rf):
 
    assert (settings.BASE_DIR / 'static' / 'about/../../settings.py').exists()
 
    request = rf.get('/about/../../settings.py')
 
    with pytest.raises(Http404):
 
        views.index(request)
0 comments (0 inline, 0 general)