Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
See #7 and #9 for more details.

- storage_service.settings.test: disable whitenoise
- locations/fixtures/package.json: use json empty document default
- Dockerfile: add p7zip missing dependency
- Dockerfile: add workdir
- Dockerfile: add pythonpath
  • Loading branch information
sevein committed Jun 20, 2017
1 parent 87c4423 commit a302168
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 45 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM python:2.7
ENV DEBIAN_FRONTEND noninteractive
ENV DJANGO_SETTINGS_MODULE storage_service.settings.production
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /src/storage_service
ENV SS_GUNICORN_BIND 0.0.0.0:8000
ENV SS_GUNICORN_CHDIR /src/storage_service
ENV SS_GUNICORN_ACCESSLOG -
Expand All @@ -14,6 +15,7 @@ RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
gettext \
p7zip-full \
rsync \
unar \
&& rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -46,4 +48,5 @@ RUN env \
/src/storage_service/manage.py collectstatic --noinput --clear

EXPOSE 8000
WORKDIR /src/storage_service
ENTRYPOINT /usr/local/bin/gunicorn --config=/etc/archivematica/storage-service.gunicorn-config.py storage_service.wsgi:application
12 changes: 6 additions & 6 deletions storage_service/locations/fixtures/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"size": 0,
"package_type": "Transfer",
"status": "Uploaded",
"misc_attributes": ""
"misc_attributes": "{}"
}
},
{
Expand All @@ -44,7 +44,7 @@
"size": 0,
"package_type": "Transfer",
"status": "Uploaded",
"misc_attributes": ""
"misc_attributes": "{}"
}
},
{
Expand All @@ -61,7 +61,7 @@
"size": 0,
"package_type": "Transfer",
"status": "Uploaded",
"misc_attributes": ""
"misc_attributes": "{}"
}
},
{
Expand All @@ -78,7 +78,7 @@
"size": 0,
"package_type": "AIP",
"status": "Uploaded",
"misc_attributes": ""
"misc_attributes": "{}"
}
},
{
Expand All @@ -95,7 +95,7 @@
"size": 0,
"package_type": "AIP",
"status": "Uploaded",
"misc_attributes": ""
"misc_attributes": "{}"
}
},
{
Expand All @@ -112,7 +112,7 @@
"size": 0,
"package_type": "AIP",
"status": "Uploaded",
"misc_attributes": ""
"misc_attributes": "{}"
}
},{
"pk": 1,
Expand Down
16 changes: 15 additions & 1 deletion storage_service/storage_service/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from os.path import abspath, basename, dirname, join, normpath
from sys import path

import dj_database_url

from django.core.exceptions import ImproperlyConfigured
from django.utils.translation import ugettext_lazy as _

Expand Down Expand Up @@ -55,9 +57,21 @@ def get_env_variable(var_name):
# Lets us know whether we're behind an HTTPS connection
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')


# ######## DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
# Configured in local/production/test configuration files
DATABASES = {}
if 'SS_DB_URL' in environ:
DATABASES['default'] = dj_database_url.config(env='SS_DB_URL', conn_max_age=600)
else:
DATABASES['default'] = {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': get_env_variable('SS_DB_NAME'),
'USER': get_env_variable('SS_DB_USER'), # Not used with sqlite3.
'PASSWORD': get_env_variable('SS_DB_PASSWORD'), # Not used with sqlite3.
'HOST': get_env_variable('SS_DB_HOST'), # Set to empty string forr localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
# ######## END DATABASE CONFIGURATION


Expand Down
22 changes: 0 additions & 22 deletions storage_service/storage_service/settings/local.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
"""Development settings and globals."""
from __future__ import absolute_import

from os import environ

import dj_database_url

from .base import * # noqa: F401, F403
from .base import get_env_variable # To make he linter happy


# ######## DEBUG CONFIGURATION
Expand All @@ -21,23 +16,6 @@
# ######## END EMAIL CONFIGURATION


# ######## DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {}
if 'SS_DB_URL' in environ:
DATABASES['default'] = dj_database_url.config(env='SS_DB_URL', conn_max_age=600)
else:
DATABASES['default'] = {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': get_env_variable('SS_DB_NAME'),
'USER': get_env_variable('SS_DB_USER'), # Not used with sqlite3.
'PASSWORD': get_env_variable('SS_DB_PASSWORD'), # Not used with sqlite3.
'HOST': get_env_variable('SS_DB_HOST'), # Set to empty string forr localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
# ######## END DATABASE CONFIGURATION


# ######## CACHE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
CACHES = {
Expand Down
17 changes: 1 addition & 16 deletions storage_service/storage_service/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# into your settings, but ImproperlyConfigured is an exception.
from django.core.exceptions import ImproperlyConfigured

import dj_database_url



def get_env_setting(setting):
Expand Down Expand Up @@ -53,21 +53,6 @@ def get_env_setting(setting):
SERVER_EMAIL = EMAIL_HOST_USER
# ######## END EMAIL CONFIGURATION

# ######## DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {}
if 'SS_DB_URL' in environ:
DATABASES['default'] = dj_database_url.config(env='SS_DB_URL', conn_max_age=600)
else:
DATABASES['default'] = {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': get_env_variable('SS_DB_NAME'),
'USER': get_env_variable('SS_DB_USER'), # Not used with sqlite3.
'PASSWORD': get_env_variable('SS_DB_PASSWORD'), # Not used with sqlite3.
'HOST': get_env_variable('SS_DB_HOST'), # Set to empty string forr localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
# ######## END DATABASE CONFIGURATION

# ######## CACHE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
Expand Down
5 changes: 5 additions & 0 deletions storage_service/storage_service/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@
'level': 'WARNING',
},
}

# Disable whitenoise
STATICFILES_STORAGE = None
if MIDDLEWARE_CLASSES[0] == 'whitenoise.middleware.WhiteNoiseMiddleware':
del MIDDLEWARE_CLASSES[0]

0 comments on commit a302168

Please sign in to comment.