Skip to content

Commit

Permalink
Added travis config.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonioo committed Mar 5, 2017
1 parent b4e7a7a commit 11d3d6c
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 4 deletions.
36 changes: 36 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
language: python
cache: pip
python:
- "2.7"

env:
- DB="POSTGRESQL"
- DB="MYSQL"

services:
- mysql
- postgres

before_install:
- pip install codecov
- if [[ $DB = 'POSTGRESQL' ]]; then pip install -q psycopg2; fi
- if [[ $DB = 'MYSQL' ]]; then pip install -q mysqlclient; fi

install:
- pip install -e git+https://github.com/tonioo/modoboa.git#egg=modoboa
- pip install -q factory-boy testfixtures
- python setup.py -q develop

before_script:
- if [[ $DB = 'POSTGRESQL' ]]; then psql -c 'create database modoboa_test;' -U postgres; fi
- if [[ $DB = 'MYSQL' ]]; then mysql -e "create database IF NOT EXISTS modoboa_test;" -uroot; fi
- if [[ $DB = 'MYSQL' ]]; then mysql -e "CREATE USER 'modoboa'@'localhost' IDENTIFIED BY 'modoboa'" -uroot; fi
- if [[ $DB = 'MYSQL' ]]; then mysql -e "GRANT ALL PRIVILEGES ON * . * TO 'modoboa'@'localhost';" -uroot; fi

script:
- cd test_project
- coverage run --source ../modoboa_amavis manage.py test modoboa_webmail

after_success:
- codecov

8 changes: 4 additions & 4 deletions modoboa_webmail/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,14 @@ def attachments(request, tplname="modoboa_webmail/attachments.html"):
@login_required
@needs_mailbox()
def delattachment(request):
if "compose_mail" not in request.session \
or "name" not in request.GET \
or not request.GET["name"]:
"""Delete an attachment."""
name = request.GET.get("name")
if not name or "compose_mail" not in request.session:
return ajax_response(request, "ko", respmsg=_("Bad query"))

error = None
for att in request.session["compose_mail"]["attachments"]:
if att["tmpname"] == request.GET["name"]:
if att["tmpname"] == name:
request.session["compose_mail"]["attachments"].remove(att)
fullpath = os.path.join(
settings.MEDIA_ROOT, "webmail", att["tmpname"]
Expand Down
10 changes: 10 additions & 0 deletions test_project/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
Empty file.
180 changes: 180 additions & 0 deletions test_project/test_project/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
"""
Django settings for test_project project.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from logging.handlers import SysLogHandler

from modoboa.test_settings import *

BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'w537@nm@5n)=+e%-7*z-jxf21a#0k%uv^rbu**+cj4=_u57e(8'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

TEMPLATE_DEBUG = False

ALLOWED_HOSTS = [
'localhost'
]

SITE_ID = 1

# Application definition

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.staticfiles',
'reversion',

)

# A dedicated place to register Modoboa applications
# Do not delete it.
# Do not change the order.
MODOBOA_APPS = (
'modoboa',
'modoboa.core',
'modoboa.lib',
'modoboa.admin',
'modoboa.relaydomains',
'modoboa.limits',
'modoboa.parameters',
# Modoboa extensions here.
'modoboa_webmail',

)

INSTALLED_APPS += MODOBOA_APPS

AUTH_USER_MODEL = 'core.User'

MIDDLEWARE_CLASSES = (
'x_forwarded_for.middleware.XForwardedForMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'modoboa.core.middleware.LocalConfigMiddleware',
'modoboa.lib.middleware.AjaxLoginRedirect',
'modoboa.lib.middleware.CommonExceptionCatcher',
'modoboa.lib.middleware.RequestCatcherMiddleware',
)

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'modoboa.core.context_processors.top_notifications',
],
'debug': False,
},
},
]

ROOT_URLCONF = 'test_project.urls'

WSGI_APPLICATION = 'test_project.wsgi.application'


# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = False

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

STATIC_URL = '/sitestatic/'
STATIC_ROOT = os.path.join(BASE_DIR, 'sitestatic')
STATICFILES_DIRS = (

)

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

# Modoboa settings
#MODOBOA_CUSTOM_LOGO = os.path.join(MEDIA_URL, "custom_logo.png")

#DOVECOT_LOOKUP_PATH = ('/path/to/dovecot', )

MODOBOA_API_URL = 'http://api.modoboa.org/1/'

# Logging configuration

LOGGING = {
'version': 1,
'formatters': {
'syslog': {
'format': '%(name)s: %(levelname)s %(message)s'
},
},
'handlers': {
'syslog-auth': {
'class': 'logging.handlers.SysLogHandler',
'facility': SysLogHandler.LOG_AUTH,
'formatter': 'syslog'
},
'modoboa': {
'class': 'modoboa.core.loggers.SQLHandler',
}
},
'loggers': {
'modoboa.auth': {
'handlers': ['syslog-auth', 'modoboa'],
'level': 'INFO',
'propagate': False
},
'modoboa.admin': {
'handlers': ['modoboa'],
'level': 'INFO',
'propagate': False
}
}
}
5 changes: 5 additions & 0 deletions test_project/test_project/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.conf.urls import include, url

urlpatterns = [
url(r'', include('modoboa.urls')),
]
14 changes: 14 additions & 0 deletions test_project/test_project/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
WSGI config for test_project project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
"""

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

0 comments on commit 11d3d6c

Please sign in to comment.