From 1b04e23b2d11f9bec8914d5229088eae59d9d934 Mon Sep 17 00:00:00 2001 From: Ashia Zed Date: Fri, 29 Oct 2021 10:27:36 -0600 Subject: [PATCH] Add postgis version to Django settings (#255) Co-authored-by: berin --- CHANGELOG.md | 1 + postgis-tests.sh | 1 + tests/conftest.py | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb2fdf4c..f55041b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased](https://github.com/model-bakers/model_bakery/tree/main) ### Added +- Added postgis version to test settings - Add support for Python 3.10 [PR #244](https://github.com/model-bakers/model_bakery/pull/244) ### Changed diff --git a/postgis-tests.sh b/postgis-tests.sh index eec9f56a..a7ff5c68 100755 --- a/postgis-tests.sh +++ b/postgis-tests.sh @@ -4,6 +4,7 @@ set -euo pipefail ### ### Run test suite against PostgreSQL DB with Postgis installed. +### Note postgis version is also explicitly set in django test settings ### ### This script will attempt to spin up a PostgreSQL Docker container against ### which the tests will be run. It will spin it down once the tests are finished, diff --git a/tests/conftest.py b/tests/conftest.py index 0e39b3fb..ab46503f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,6 +15,7 @@ def pytest_configure(): ] using_postgres_flag = False + postgis_version = () if test_db == "sqlite": db_engine = "django.db.backends.sqlite3" db_name = ":memory:" @@ -34,6 +35,7 @@ def pytest_configure(): "django.contrib.postgres", "django.contrib.gis", ] + installed_apps + postgis_version = (11, 3, 0) else: raise NotImplementedError("Tests for % are not supported", test_db) @@ -66,6 +68,9 @@ def pytest_configure(): MIDDLEWARE=(), USE_TZ=os.environ.get("USE_TZ", False), USING_POSTGRES=using_postgres_flag, + # Set the version explicitly otherwise Django does extra queries + # to get the version via SQL when using POSTGIS + POSTGIS_VERSION=postgis_version, ) from model_bakery import baker