mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
codecov
This commit is contained in:
+12
-4
@@ -2,13 +2,21 @@ language: python
|
||||
python:
|
||||
- "2.7"
|
||||
|
||||
before_install:
|
||||
- pip install codecov
|
||||
|
||||
install:
|
||||
- python setup.py -q install
|
||||
- pip install -q MySQL-python --use-mirrors
|
||||
- pip install -q pexpect --use-mirrors
|
||||
- pip install -q psycopg2
|
||||
|
||||
before_script:
|
||||
- mysql -e 'create database modoboa_test;'
|
||||
- psql -c 'create database modoboa_test;' -U postgres
|
||||
|
||||
script:
|
||||
- PYTHONPATH=tests python -m unittest install_from_scratch.DeployTest.test_silent
|
||||
- python ./tests.py
|
||||
- cd test_project
|
||||
- coverage run --source ../modoboa manage.py test modoboa.core.tests modoboa.lib.tests
|
||||
|
||||
after_success:
|
||||
- codecov
|
||||
|
||||
Executable
+10
@@ -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)
|
||||
@@ -0,0 +1,176 @@
|
||||
"""
|
||||
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 django.conf import global_settings
|
||||
|
||||
|
||||
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 = '!8o(-dbbl3e+*bh7nx-^xysdt)1gso*%@4ze4-9_9o+i&t--u_'
|
||||
|
||||
# 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 extensions here.
|
||||
|
||||
)
|
||||
|
||||
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.lib.middleware.AjaxLoginRedirect',
|
||||
'modoboa.lib.middleware.CommonExceptionCatcher',
|
||||
'modoboa.lib.middleware.RequestCatcherMiddleware',
|
||||
)
|
||||
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
'modoboa.lib.authbackends.SimpleBackend',
|
||||
)
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
|
||||
'modoboa.core.context_processors.top_notifications',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'test_project.urls'
|
||||
|
||||
WSGI_APPLICATION = 'test_project.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'modoboa_test',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': '',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '',
|
||||
'ATOMIC_REQUESTS': True,
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
# 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 = (
|
||||
'/home/tonio/.pythonenvs/modoboa/lib/python2.7/site-packages/modoboa-1.3.3-py2.7.egg/modoboa/bower_components',
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.conf.urls import patterns, include, url
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'', include('modoboa.urls')),
|
||||
)
|
||||
@@ -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,0 +1,33 @@
|
||||
# coding: utf-8
|
||||
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from modoboa.lib.sysutils import exec_cmd
|
||||
|
||||
|
||||
class DeployTest(unittest.TestCase):
|
||||
dbtype = "postgres"
|
||||
dbhost = "localhost"
|
||||
projname = "modoboa_test"
|
||||
dbuser = "postgres"
|
||||
dbpassword = ""
|
||||
|
||||
def setUp(self):
|
||||
self.workdir = tempfile.mkdtemp()
|
||||
|
||||
def test_silent(self):
|
||||
dburl = "default:%s://%s:%s@%s/%s" \
|
||||
% (self.dbtype, self.dbuser, self.dbpassword,
|
||||
self.dbhost, self.projname)
|
||||
cmd = (
|
||||
"modoboa-admin.py deploy --collectstatic "
|
||||
"--dburl %s --domain %s %s"
|
||||
% (dburl, 'localhost', self.projname)
|
||||
)
|
||||
code, output = exec_cmd(cmd, cwd=self.workdir)
|
||||
self.assertEqual(code, 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -1,71 +0,0 @@
|
||||
# coding: utf-8
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import pexpect
|
||||
import unittest
|
||||
|
||||
from modoboa.lib.sysutils import exec_cmd
|
||||
|
||||
|
||||
class DeployTest(unittest.TestCase):
|
||||
dbtype = "mysql"
|
||||
dbhost = "localhost"
|
||||
projname = "modoboa_test"
|
||||
dbuser = "travis"
|
||||
dbpassword = ""
|
||||
|
||||
def setUp(self):
|
||||
self.workdir = tempfile.mkdtemp()
|
||||
|
||||
def tearDown(self):
|
||||
path = os.path.join(self.workdir, self.projname)
|
||||
core_apps = ["modoboa.core", "modoboa.lib"]
|
||||
cmd = "python manage.py test {0}".format(
|
||||
" ".join(core_apps),
|
||||
)
|
||||
code, output = exec_cmd(cmd, capture_output=False, cwd=path)
|
||||
self.assertEqual(code, 0)
|
||||
|
||||
def test_standard(self):
|
||||
timeout = 2
|
||||
cmd = (
|
||||
"modoboa-admin.py deploy --collectstatic {0}"
|
||||
.format(self.projname)
|
||||
)
|
||||
child = pexpect.spawn(cmd, cwd=self.workdir)
|
||||
fout = open('install_from_scratch.log', 'w')
|
||||
child.logfile = fout
|
||||
child.expect("Database type \(mysql, postgres or sqlite3\):", timeout=timeout)
|
||||
child.sendline(self.dbtype)
|
||||
child.expect("Database host \(default: 'localhost'\):", timeout=timeout)
|
||||
child.sendline(self.dbhost)
|
||||
child.expect("Database port \(default: '3306'\):", timeout=timeout)
|
||||
child.sendline('3306')
|
||||
child.expect("Database name:", timeout=timeout)
|
||||
child.sendline(self.projname)
|
||||
child.expect("Username:", timeout=timeout)
|
||||
child.sendline(self.dbuser)
|
||||
child.expect("Password:", timeout=timeout)
|
||||
child.sendline(self.dbpassword)
|
||||
child.expect("Under which domain do you want to deploy modoboa?", timeout=timeout)
|
||||
child.sendline("localhost")
|
||||
child.wait()
|
||||
fout.close()
|
||||
self.assertEqual(child.exitstatus, 0)
|
||||
|
||||
def test_silent(self):
|
||||
dburl = "default:%s://%s:%s@%s/%s" \
|
||||
% (self.dbtype, self.dbuser, self.dbpassword,
|
||||
self.dbhost, self.projname)
|
||||
cmd = (
|
||||
"modoboa-admin.py deploy --collectstatic "
|
||||
"--dburl %s --domain %s %s"
|
||||
% (dburl, 'localhost', self.projname)
|
||||
)
|
||||
code, output = exec_cmd(cmd, cwd=self.workdir)
|
||||
self.assertEqual(code, 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user