Skip to content

Commit 37f3218

Browse files
committed
move to single package
1 parent 0b958e7 commit 37f3218

File tree

10 files changed

+74
-27
lines changed

10 files changed

+74
-27
lines changed

.github/workflows/test-python-geo.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Python Tests with GeoDjango
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**.py'
7+
- '!setup.py'
8+
- '.github/workflows/test-python.yml'
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
defaults:
16+
run:
17+
shell: bash -eux {0}
18+
19+
jobs:
20+
build:
21+
name: Django Test Suite
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout django-mongodb-backend
25+
uses: actions/checkout@v4
26+
with:
27+
persist-credentials: false
28+
- name: install django-mongodb-backend
29+
run: |
30+
pip3 install --upgrade pip
31+
pip3 install -e .
32+
- name: Checkout Django
33+
uses: actions/checkout@v4
34+
with:
35+
repository: 'mongodb-forks/django'
36+
ref: 'mongogis'
37+
path: 'django_repo'
38+
persist-credentials: false
39+
- name: Install system packages for Django's Python test dependencies
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install gdal-bin libmemcached-dev
43+
- name: Install Django and its Python test dependencies
44+
run: |
45+
cd django_repo/tests/
46+
pip3 install -e ..
47+
pip3 install -r requirements/py3.txt
48+
- name: Copy the test settings file
49+
run: cp .github/workflows/mongodb_settings.py django_repo/tests/
50+
- name: Copy the test runner file
51+
run: cp .github/workflows/runtests.py django_repo/tests/runtests_.py
52+
- name: Start MongoDB
53+
uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0
54+
with:
55+
mongodb-version: 6.0
56+
- name: Run tests
57+
run: python3 django_repo/tests/runtests_.py

django_mongodb_backend/features.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
from django.utils.functional import cached_property
33
from pymongo.errors import OperationFailure
44

5+
from .gis.features import GISFeatures
56

6-
class DatabaseFeatures(BaseDatabaseFeatures):
7+
8+
class DatabaseFeatures(GISFeatures, BaseDatabaseFeatures):
79
minimum_database_version = (6, 0)
810
allow_sliced_subqueries_with_in = False
911
allows_multiple_constraints_on_same_fields = False
@@ -135,7 +137,7 @@ def django_test_expected_failures(self):
135137
expected_failures.update(self._django_test_expected_failures_no_transactions)
136138
return expected_failures
137139

138-
django_test_skips = {
140+
_django_test_skips = {
139141
"Database defaults aren't supported by MongoDB.": {
140142
# bson.errors.InvalidDocument: cannot encode object:
141143
# <django.db.models.expressions.DatabaseDefault
@@ -588,6 +590,12 @@ def django_test_expected_failures(self):
588590
},
589591
}
590592

593+
@cached_property
594+
def django_test_skips(self):
595+
skips = super().django_test_skips
596+
skips.update(self._django_test_skips)
597+
return skips
598+
591599
@cached_property
592600
def is_mongodb_6_3(self):
593601
return self.connection.get_database_version() >= (6, 3)

django_mongodb_backend_gis/features.py renamed to django_mongodb_backend/gis/features.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
22
from django.utils.functional import cached_property
33

4-
from django_mongodb_backend.features import DatabaseFeatures as MongoFeatures
54

6-
7-
class DatabaseFeatures(BaseSpatialFeatures, MongoFeatures):
5+
class GISFeatures(BaseSpatialFeatures):
86
has_spatialrefsys_table = False
97
supports_transform = False
108

@@ -18,15 +16,14 @@ def django_test_expected_failures(self):
1816
"gis_tests.geoapp.tests.GeoModelTest.test_proxy",
1917
# MongoDB does not support the within lookup
2018
"gis_tests.relatedapp.tests.RelatedGeoModelTest.test06_f_expressions",
19+
"gis_tests.geoapp.tests.GeoModelTest.test_gis_query_as_string",
2120
# 'Adapter' object has no attribute 'srid'
2221
"gis_tests.geoapp.test_expressions.GeoExpressionsTests.test_geometry_value_annotation",
2322
# Object of type ObjectId is not JSON serializable
2423
"gis_tests.geoapp.test_serializers.GeoJSONSerializerTests.test_fields_option",
2524
"gis_tests.geoapp.test_serializers.GeoJSONSerializerTests.test_geometry_field_option",
2625
"gis_tests.geoapp.test_serializers.GeoJSONSerializerTests.test_serialization_base",
2726
"gis_tests.geoapp.test_serializers.GeoJSONSerializerTests.test_srid_option",
28-
# KeyError: 'within' connection.ops.gis_operators[self.lookup_name]
29-
"gis_tests.geoapp.tests.GeoModelTest.test_gis_query_as_string",
3027
# No lookups are supported (yet?)
3128
"gis_tests.geoapp.tests.GeoLookupTest.test_gis_lookups_with_complex_expressions",
3229
# Trying to remove spatial index fails:

django_mongodb_backend_gis/operations.py renamed to django_mongodb_backend/gis/operations.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22
from django.contrib.gis.db import models
33
from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations
44

5-
from django_mongodb_backend.operations import (
6-
DatabaseOperations as MongoOperations,
7-
)
8-
95
from .adapter import Adapter
106

117

12-
class DatabaseOperations(BaseSpatialOperations, MongoOperations):
8+
class GISOperations(BaseSpatialOperations):
139
Adapter = Adapter
1410

1511
disallowed_aggregates = (

django_mongodb_backend_gis/schema.py renamed to django_mongodb_backend/gis/schema.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
from pymongo import GEOSPHERE
22
from pymongo.operations import IndexModel
33

4-
from django_mongodb_backend.schema import DatabaseSchemaEditor as BaseSchemaEditor
54

6-
7-
class DatabaseSchemaEditor(BaseSchemaEditor):
5+
class GISSchemaEditor:
86
def _field_should_be_indexed(self, model, field):
97
if getattr(field, "spatial_index", False):
108
return True

django_mongodb_backend/operations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
from django.utils import timezone
1515
from django.utils.regex_helper import _lazy_re_compile
1616

17+
from .gis.operations import GISOperations
1718

18-
class DatabaseOperations(BaseDatabaseOperations):
19+
20+
class DatabaseOperations(GISOperations, BaseDatabaseOperations):
1921
compiler_module = "django_mongodb_backend.compiler"
2022
combine_operators = {
2123
Combinable.ADD: "add",

django_mongodb_backend_gis/base.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)