-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import pytest | ||
from django.urls import reverse | ||
|
||
from adhocracy4.projects.models import Project | ||
from adhocracy4.test import helpers | ||
|
||
# Define a GeoJSON point | ||
geojson_point = { | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": {"type": "Point", "coordinates": [1.0, 1.0]}, | ||
} | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_project_with_geojson_point(project_factory): | ||
project = project_factory(is_app_accessible=True) | ||
|
||
# Create a Project instance with the GeoJSON point | ||
project.point = geojson_point | ||
project.save() | ||
|
||
fetched_project = Project.objects.get(id=project.id) | ||
|
||
# Check if the point is correctly stored | ||
assert fetched_project.point == geojson_point | ||
print(fetched_project.point) | ||
assert fetched_project.point["geometry"]["coordinates"] == [ | ||
1.0, | ||
1.0, | ||
] # Check coordinates | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_project_geojson_point_serialiser( | ||
user, project_factory, module_factory, phase_factory, apiclient | ||
): | ||
project = project_factory(is_app_accessible=True, point=geojson_point) | ||
module = module_factory(project=project) | ||
# module_factory(project=project, is_draft=True) | ||
phase = phase_factory(module=module) | ||
|
||
url = reverse("app-projects-list") | ||
apiclient.login(username=user.email, password="password") | ||
with helpers.freeze_phase(phase): | ||
response = apiclient.get(url, format="json") | ||
|
||
assert response.status_code == 200 | ||
assert response.data[0]["point"] == str(geojson_point) |