mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-13 19:56:25 +00:00
Use real database (side container)
This commit is contained in:
@@ -14,6 +14,15 @@ variables:
|
|||||||
test_and_coverage:
|
test_and_coverage:
|
||||||
stage: build
|
stage: build
|
||||||
coverage: "/^TOTAL.*\\s+(\\d+\\%)$/"
|
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:
|
before_script:
|
||||||
- virtualenv -p python3 /tmp/.virtualenv
|
- virtualenv -p python3 /tmp/.virtualenv
|
||||||
- source /tmp/.virtualenv/bin/activate
|
- source /tmp/.virtualenv/bin/activate
|
||||||
@@ -31,8 +40,9 @@ test_and_coverage:
|
|||||||
- echo "DEBUG = True" >> config_local.py
|
- echo "DEBUG = True" >> config_local.py
|
||||||
- echo "from config import CACHES" >> config_local.py
|
- echo "from config import CACHES" >> config_local.py
|
||||||
- echo "CACHES['default'] = CACHES['filesystem']" >> config_local.py
|
- echo "CACHES['default'] = CACHES['filesystem']" >> config_local.py
|
||||||
|
- python manage.py sqldsn
|
||||||
- python manage.py collectstatic --noinput
|
- 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 report --fail-under=70
|
||||||
- coverage html
|
- coverage html
|
||||||
artifacts:
|
artifacts:
|
||||||
|
|||||||
13
config.py
13
config.py
@@ -153,6 +153,19 @@ if "POSTGRESQL_DATABASE" in os.environ:
|
|||||||
"HOST": "postgresql",
|
"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"
|
SESSION_SERIALIZER = "django.contrib.sessions.serializers.JSONSerializer"
|
||||||
|
|
||||||
USE_X_FORWARDED_HOST = True
|
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
|
# Probably not the best way to access the content type
|
||||||
self.assertEqual(response["Content-Type"], "image/jpg", "Content type wrong!?")
|
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(
|
self.assertEqual(
|
||||||
response.content,
|
bytes(response.content),
|
||||||
self.user.photo_set.first().data,
|
bytes(self.user.photo_set.first().data),
|
||||||
"raw_image should return the same content as if we\
|
"raw_image should return the same content as if we\
|
||||||
read it directly from the DB",
|
read it directly from the DB",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user