mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-21 09:31:09 -05:00
Add comprehensive tests for Parks API and models
- Implemented extensive test cases for the Parks API, covering endpoints for listing, retrieving, creating, updating, and deleting parks. - Added tests for filtering, searching, and ordering parks in the API. - Created tests for error handling in the API, including malformed JSON and unsupported methods. - Developed model tests for Park, ParkArea, Company, and ParkReview models, ensuring validation and constraints are enforced. - Introduced utility mixins for API and model testing to streamline assertions and enhance test readability. - Included integration tests to validate complete workflows involving park creation, retrieval, updating, and deletion.
This commit is contained in:
@@ -12,9 +12,9 @@ from .models import (
|
||||
Ride, RollerCoasterStats, RideModel,
|
||||
CATEGORY_CHOICES, Company
|
||||
)
|
||||
from .forms import RideForm
|
||||
from .forms import RideForm, RideSearchForm
|
||||
from parks.models import Park
|
||||
from core.views import SlugRedirectMixin
|
||||
from core.views.views import SlugRedirectMixin
|
||||
from moderation.mixins import EditSubmissionMixin, PhotoSubmissionMixin, HistoryMixin
|
||||
from moderation.models import EditSubmission
|
||||
|
||||
@@ -418,14 +418,12 @@ class RideSearchView(ListView):
|
||||
|
||||
def get_queryset(self):
|
||||
"""Get filtered rides based on search form."""
|
||||
from services.search import RideSearchForm
|
||||
|
||||
queryset = Ride.objects.select_related('park').order_by('name')
|
||||
|
||||
# Process search form
|
||||
form = RideSearchForm(self.request.GET)
|
||||
if form.is_valid():
|
||||
ride = form.cleaned_data.get('ride')
|
||||
ride = form.cleaned_data.get("ride")
|
||||
if ride:
|
||||
# If specific ride selected, return just that ride
|
||||
queryset = queryset.filter(id=ride.id)
|
||||
@@ -445,8 +443,6 @@ class RideSearchView(ListView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Add search form to context."""
|
||||
from search.forms import RideSearchForm
|
||||
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['search_form'] = RideSearchForm(self.request.GET)
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user