Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#22632 closed Cleanup/optimization (fixed)

Spatial backend tests uses hardcoded set of backends

Reported by: Jani Tiainen Owned by: nobody
Component: GIS Version: master
Severity: Normal Keywords: gis database testing
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django.contrib.gis.tests.utils is hardcoded parts that spatial backend must be located inside 'django.contrib.gis' and there are bunch of hardcoded imports depending on selected backend.

This makes impossible to test any custom backend for GIS options.

Change History (12)

comment:1 Changed 2 years ago by Claude Paroz

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

You are referring to has_spatial_db, I suppose. You are right, however it's a bit tricky because that utility is used many times during test modules import time. We have to be careful not to have to load too much things to determine if the backend is gis-enabled or not.

comment:2 Changed 2 years ago by Claude Paroz

One more thing, we should follow the work recently done to abstract the backend name and concentrate on backend capabilities instead. See c70a61eb49e4ed8f3b2a5011a7a5e6cda43c8598 and commits around it.

comment:3 Changed 2 years ago by Claude Paroz

Has patch: set
Version: 1.6master

In that pull request (https://github.com/django/django/pull/3080), I set the base to use connection.features to test for various GIS features. As a start and proof of concept, I got rid of HAS_SPATIAL_DB. Reviews welcome.

comment:4 Changed 2 years ago by Claude Paroz <claude@…>

In 6295ea0027d808dcc309aa42cc58f6fdf172c3fc:

Replaced HAS_SPATIAL_DB by testing database feature

Refs #22632. This should be the base for using more database
features to exclude specific backends in GIS tests.
Thanks Tim Graham for the review.

comment:5 Changed 2 years ago by Claude Paroz

comment:6 Changed 2 years ago by Claude Paroz <claude@…>

In a7d964ab87ad7352af3e33b8f3c12e4643a80f02:

Replaced no_spatialite by connection features

Refs #22632. Thanks Tim Graham for the review.

comment:7 Changed 2 years ago by Claude Paroz <claude@…>

In ba1d707b0f5666809b09bb8234f2df64bf0d7490:

Replaced no_mysql by connection features

Refs #22632. Thanks Tim Graham for the review.

comment:8 Changed 2 years ago by Claude Paroz

A few more here: https://github.com/django/django/pull/3109

Note that I'm not able to test those changes on Oracle GIS. If anyone has this ability and some time to spent, feel free to help! I also won't able to tackle the remaining no_oracle flags.

comment:9 Changed 2 years ago by Claude Paroz <claude@…>

In 60428ed5db76f509f4a0eb737d96b4f0ae6b0ad5:

Removed some more hardcoded backends in GIS tests

Refs #22632. Thanks Tim Graham for the review.

comment:10 Changed 2 years ago by Claude Paroz

Resolution: fixed
Status: newclosed

I think that now about 90% of hardcoded references to backends have been replaced by database features, which should allow custom backends to run GIS tests. There is probably some work remaining, but I suggest now to open individual tickets for such issues.

comment:11 Changed 2 years ago by Tim Graham <timograham@…>

In 6c1a0581abd9cf21fa37c6c9e9937986da45005c:

Added a feature flag for add_srs_entry support; refs #22632 and #23504.

comment:12 Changed 2 years ago by Tim Graham <timograham@…>

In 33e817a6d8b163aa6e8a2fb15d7269d1ecbbcf59:

Added feature flag for geometry_field_introspection; refs #22632 and #23504.

Note: See TracTickets for help on using tickets.
Back to Top