-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2255 from onaio/add-geojson-simplestyle-spec-support
Add geojson simplestyle-spec support
- Loading branch information
Showing
4 changed files
with
189 additions
and
38 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
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,23 @@ | ||
from rest_framework.test import APIRequestFactory | ||
from django.contrib.gis.geos import GeometryCollection, Point | ||
|
||
from onadata.libs.serializers.geojson_serializer import GeoJsonSerializer | ||
from onadata.apps.api.tests.viewsets.test_abstract_viewset import TestAbstractViewSet | ||
|
||
|
||
class TestGeoJsonSerializer(TestAbstractViewSet): | ||
def setUp(self): | ||
self._login_user_and_profile() | ||
self.factory = APIRequestFactory() | ||
|
||
def test_geojson_serializer(self): | ||
self._publish_xls_form_to_project() | ||
data = { | ||
"xform": self.xform.id, | ||
"geom": GeometryCollection(Point([6.707548, 6.423264])), | ||
} | ||
request = self.factory.get("/", **self.extra) | ||
serializer = GeoJsonSerializer(data=data, context={"request": request}) | ||
self.assertTrue(serializer.is_valid()) | ||
geometry = serializer.validated_data["geom"] | ||
self.assertEqual(geometry.geojson, data.get("geom").geojson) |