mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-14 04:04:03 +00:00
Use real database (side container)
This commit is contained in:
@@ -14,6 +14,15 @@ variables:
|
||||
test_and_coverage:
|
||||
stage: build
|
||||
coverage: "/^TOTAL.*\\s+(\\d+\\%)$/"
|
||||
services:
|
||||
- postgres:latest
|
||||
variables:
|
||||
POSTGRES_DB: django_db
|
||||
POSTGRES_USER: django_user
|
||||
POSTGRES_PASSWORD: django_password
|
||||
POSTGRES_HOST: postgres
|
||||
DATABASE_URL: "postgres://django_user:django_password@postgres/django_db"
|
||||
PYTHONUNBUFFERED: 1
|
||||
before_script:
|
||||
- virtualenv -p python3 /tmp/.virtualenv
|
||||
- source /tmp/.virtualenv/bin/activate
|
||||
@@ -31,8 +40,9 @@ test_and_coverage:
|
||||
- echo "DEBUG = True" >> config_local.py
|
||||
- echo "from config import CACHES" >> config_local.py
|
||||
- echo "CACHES['default'] = CACHES['filesystem']" >> config_local.py
|
||||
- python manage.py sqldsn
|
||||
- python manage.py collectstatic --noinput
|
||||
- coverage run --source . manage.py test -v3
|
||||
- coverage run --source . manage.py test -v3 --noinput
|
||||
- coverage report --fail-under=70
|
||||
- coverage html
|
||||
artifacts:
|
||||
|
||||
13
config.py
13
config.py
@@ -153,6 +153,19 @@ if "POSTGRESQL_DATABASE" in os.environ:
|
||||
"HOST": "postgresql",
|
||||
}
|
||||
|
||||
# CI/CD config has different naming
|
||||
if "POSTGRES_DB" in os.environ:
|
||||
DATABASES["default"] = { # pragma: no cover
|
||||
"ENGINE": "django.db.backends.postgresql",
|
||||
"NAME": os.environ["POSTGRES_DB"],
|
||||
"USER": os.environ["POSTGRES_USER"],
|
||||
"PASSWORD": os.environ["POSTGRES_PASSWORD"],
|
||||
"HOST": os.environ["POSTGRES_HOST"],
|
||||
"TEST": {
|
||||
"NAME": os.environ["POSTGRES_DB"],
|
||||
},
|
||||
}
|
||||
|
||||
SESSION_SERIALIZER = "django.contrib.sessions.serializers.JSONSerializer"
|
||||
|
||||
USE_X_FORWARDED_HOST = True
|
||||
|
||||
@@ -394,9 +394,11 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
||||
# Probably not the best way to access the content type
|
||||
self.assertEqual(response["Content-Type"], "image/jpg", "Content type wrong!?")
|
||||
|
||||
print("XXX: %s", type(response.content))
|
||||
print("XXX: %s", type(self.user.photo_set.first().data))
|
||||
self.assertEqual(
|
||||
response.content,
|
||||
self.user.photo_set.first().data,
|
||||
bytes(response.content),
|
||||
bytes(self.user.photo_set.first().data),
|
||||
"raw_image should return the same content as if we\
|
||||
read it directly from the DB",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user