Skip to content

Commit

Permalink
Add postgis version to Django settings (#255)
Browse files Browse the repository at this point in the history
Co-authored-by: berin <bernardoxhc@gmail.com>
  • Loading branch information
ashiazed and berinhard committed Oct 29, 2021
1 parent b764f36 commit 1b04e23
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions postgis-tests.sh
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Expand Up @@ -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:"
Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1b04e23

Please sign in to comment.