mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 05:51:08 -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:
50
location/migrations/0002_add_business_constraints.py
Normal file
50
location/migrations/0002_add_business_constraints.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# Generated by Django 5.2.5 on 2025-08-16 17:42
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("contenttypes", "0002_remove_content_type_name"),
|
||||
("location", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddConstraint(
|
||||
model_name="location",
|
||||
constraint=models.CheckConstraint(
|
||||
condition=models.Q(
|
||||
("latitude__isnull", True),
|
||||
models.Q(("latitude__gte", -90), ("latitude__lte", 90)),
|
||||
_connector="OR",
|
||||
),
|
||||
name="location_latitude_range",
|
||||
violation_error_message="Latitude must be between -90 and 90 degrees",
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="location",
|
||||
constraint=models.CheckConstraint(
|
||||
condition=models.Q(
|
||||
("longitude__isnull", True),
|
||||
models.Q(("longitude__gte", -180), ("longitude__lte", 180)),
|
||||
_connector="OR",
|
||||
),
|
||||
name="location_longitude_range",
|
||||
violation_error_message="Longitude must be between -180 and 180 degrees",
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="location",
|
||||
constraint=models.CheckConstraint(
|
||||
condition=models.Q(
|
||||
models.Q(("latitude__isnull", True), ("longitude__isnull", True)),
|
||||
models.Q(("latitude__isnull", False), ("longitude__isnull", False)),
|
||||
_connector="OR",
|
||||
),
|
||||
name="location_coordinates_complete",
|
||||
violation_error_message="Both latitude and longitude must be provided together",
|
||||
),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user