Merge branch 'master' of github.com:tonioo/modoboa

This commit is contained in:
Antoine Nguyen
2016-03-16 11:39:27 +01:00
5 changed files with 63 additions and 29 deletions
+15 -4
View File
@@ -3,22 +3,33 @@ language: python
python:
- "2.7"
env:
- DB="POSTGRESQL"
- DB="MYSQL"
services:
- mysql
- postgres
before_install:
- pip install codecov
install:
- python setup.py -q develop
- pip install -q psycopg2
- pip install -q psycopg2 mysqlclient
- pip install -q -r test-requirements.txt
before_script:
- psql -c 'create database modoboa_test;' -U postgres
- mysql -e "create database IF NOT EXISTS modoboa_test;" -uroot
- mysql -e "CREATE USER 'modoboa'@'localhost' IDENTIFIED BY 'modoboa'" -uroot;
- mysql -e "GRANT ALL PRIVILEGES ON * . * TO 'modoboa'@'localhost';" -uroot;
script:
script:
- python ./tests.py
- cd test_project
- coverage run --source ../modoboa manage.py test modoboa.core modoboa.lib modoboa.admin.tests modoboa.limits modoboa.relaydomains
after_success:
- codecov
+3 -2
View File
@@ -32,11 +32,12 @@ class DomainAPITestCase(ModoAPITestCase):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data), 2)
domain = response.data[0]
url = reverse(
"external_api:domain-detail", args=[response.data[0]["pk"]])
"external_api:domain-detail", args=[domain["pk"]])
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data["name"], "test2.com")
self.assertEqual(response.data["name"], domain["name"])
def test_create_domain(self):
"""Check domain creation."""
+38
View File
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
import os
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DB = os.environ.get('DB', 'POSTGRES')
if DB == 'MYSQL':
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'modoboa_test',
'USER': 'modoboa',
'PASSWORD': 'modoboa',
'HOST': 'localhost',
'PORT': '',
'ATOMIC_REQUESTS': True,
},
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'modoboa_test',
'USER': 'postgres',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '',
'ATOMIC_REQUESTS': True,
},
}
+1 -19
View File
@@ -14,6 +14,7 @@ from logging.handlers import SysLogHandler
from django.conf import global_settings
from modoboa.test_settings import *
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
@@ -91,24 +92,6 @@ 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/
@@ -185,4 +168,3 @@ LOGGING = {
}
}
}
+6 -4
View File
@@ -1,17 +1,19 @@
# coding: utf-8
import os
import tempfile
import unittest
from modoboa.lib.sysutils import exec_cmd
DB = os.environ.get("DB", "postgres")
class DeployTest(unittest.TestCase):
dbtype = "postgres"
dbtype = DB.lower()
dbhost = "localhost"
projname = "modoboa_test"
dbuser = "postgres"
dbpassword = ""
dbuser = DB == "MYSQL" and "modoboa" or "postgres"
dbpassword = DB == "MYSQL" and "modoboa" or ""
def setUp(self):
self.workdir = tempfile.mkdtemp()