2015-11-01 17:10:52 +01:00
|
|
|
from __future__ import absolute_import
|
2013-01-10 19:05:53 +01:00
|
|
|
import os
|
2016-10-06 01:42:24 +02:00
|
|
|
# test_settings.py works differently from
|
|
|
|
# dev_settings.py/prod_settings.py; it actually is directly referenced
|
|
|
|
# by the test suite as DJANGO_SETTINGS_MODULE and imports settings.py
|
|
|
|
# directly and then hacks up the values that are different for the
|
|
|
|
# test suite. As will be explained, this is kinda messy and probably
|
|
|
|
# we'd be better off switching it to work more like dev_settings.py,
|
|
|
|
# but for now, this is what we have.
|
|
|
|
#
|
|
|
|
# An important downside of the test_settings.py approach is that if we
|
|
|
|
# want to change any settings that settings.py then computes
|
|
|
|
# additional settings from (e.g. EXTERNAL_HOST), we need to do a hack
|
|
|
|
# like the below line(s) before we import from settings, for
|
|
|
|
# transmitting the value of EXTERNAL_HOST to dev_settings.py so that
|
|
|
|
# it can be set there, at the right place in the settings.py flow.
|
|
|
|
# Ick.
|
|
|
|
if os.getenv("EXTERNAL_HOST") is None:
|
|
|
|
os.environ["EXTERNAL_HOST"] = "testserver"
|
|
|
|
from .settings import *
|
2012-10-02 17:57:46 +02:00
|
|
|
|
2016-12-28 05:16:12 +01:00
|
|
|
DATABASES["default"] = {
|
|
|
|
"NAME": "zulip_test",
|
|
|
|
"USER": "zulip_test",
|
|
|
|
"PASSWORD": LOCAL_DATABASE_PASSWORD,
|
|
|
|
"HOST": "localhost",
|
|
|
|
"SCHEMA": "zulip",
|
|
|
|
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
|
|
|
"TEST_NAME": "django_zulip_tests",
|
|
|
|
"OPTIONS": {"connection_factory": TimeTrackingConnection},
|
|
|
|
}
|
2016-09-18 18:03:43 +02:00
|
|
|
if USING_PGROONGA:
|
|
|
|
# We need to have "pgroonga" schema before "pg_catalog" schema in
|
|
|
|
# the PostgreSQL search path, because "pgroonga" schema overrides
|
|
|
|
# the "@@" operator from "pg_catalog" schema, and "pg_catalog"
|
|
|
|
# schema is searched first if not specified in the search path.
|
|
|
|
# See also: http://www.postgresql.org/docs/current/static/runtime-config-client.html
|
|
|
|
pg_options = '-c search_path=%(SCHEMA)s,zulip,public,pgroonga,pg_catalog' % \
|
|
|
|
DATABASES['default']
|
|
|
|
DATABASES['default']['OPTIONS']['options'] = pg_options
|
2013-05-08 05:30:42 +02:00
|
|
|
|
2016-06-30 23:07:30 +02:00
|
|
|
# In theory this should just go in zproject/settings.py inside the `if
|
2016-07-04 09:33:57 +02:00
|
|
|
# PIPELINE_ENABLED` statement, but because zproject/settings.py is processed
|
2016-06-30 23:07:30 +02:00
|
|
|
# first, we have to add it here as a hack.
|
|
|
|
JS_SPECS['app']['source_filenames'].append('js/bundle.js')
|
2012-11-09 18:13:16 +01:00
|
|
|
|
2013-01-10 19:05:53 +01:00
|
|
|
if "TORNADO_SERVER" in os.environ:
|
2016-04-28 07:32:27 +02:00
|
|
|
# This covers the Casper test suite case
|
2013-01-10 19:05:53 +01:00
|
|
|
TORNADO_SERVER = os.environ["TORNADO_SERVER"]
|
|
|
|
else:
|
2016-04-28 07:32:27 +02:00
|
|
|
# This covers the backend test suite case
|
2013-01-10 19:05:53 +01:00
|
|
|
TORNADO_SERVER = None
|
2016-04-28 07:32:27 +02:00
|
|
|
CAMO_URI = 'https://external-content.zulipcdn.net/'
|
|
|
|
CAMO_KEY = 'dummy'
|
2012-12-11 18:12:40 +01:00
|
|
|
|
2016-12-15 07:02:42 +01:00
|
|
|
if "CASPER_TESTS" in os.environ:
|
|
|
|
CASPER_TESTS = True
|
|
|
|
|
2012-12-11 18:12:40 +01:00
|
|
|
# Decrease the get_updates timeout to 1 second.
|
|
|
|
# This allows CasperJS to proceed quickly to the next test step.
|
|
|
|
POLL_TIMEOUT = 1000
|
2013-01-09 00:10:37 +01:00
|
|
|
|
2013-01-10 19:05:53 +01:00
|
|
|
# Don't use the real message log for tests
|
2013-10-31 19:07:43 +01:00
|
|
|
EVENT_LOG_DIR = '/tmp/zulip-test-event-log'
|
2013-01-10 19:05:53 +01:00
|
|
|
|
|
|
|
# Print our emails rather than sending them
|
|
|
|
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
|
2013-01-10 19:41:49 +01:00
|
|
|
|
2015-08-20 08:34:25 +02:00
|
|
|
# The test suite uses EmailAuthBackend
|
|
|
|
AUTHENTICATION_BACKENDS += ('zproject.backends.EmailAuthBackend',)
|
|
|
|
|
2016-09-13 21:30:18 +02:00
|
|
|
# Configure Google Oauth2
|
|
|
|
GOOGLE_OAUTH2_CLIENT_ID = "test_client_id"
|
|
|
|
|
2016-04-21 18:34:54 +02:00
|
|
|
# Makes testing LDAP backend require less mocking
|
|
|
|
AUTH_LDAP_ALWAYS_UPDATE_USER = False
|
|
|
|
|
2013-01-10 19:41:49 +01:00
|
|
|
TEST_SUITE = True
|
2013-05-29 23:58:07 +02:00
|
|
|
RATE_LIMITING = False
|
2013-01-11 21:16:42 +01:00
|
|
|
# Don't use rabbitmq from the test suite -- the user_profile_ids for
|
|
|
|
# any generated queue elements won't match those being used by the
|
|
|
|
# real app.
|
|
|
|
USING_RABBITMQ = False
|
|
|
|
|
2013-03-18 18:40:47 +01:00
|
|
|
# Disable the tutorial because it confuses the client tests.
|
|
|
|
TUTORIAL_ENABLED = False
|
|
|
|
|
2013-01-10 19:05:53 +01:00
|
|
|
# Disable use of memcached for caching
|
2013-07-02 23:29:00 +02:00
|
|
|
CACHES['database'] = {
|
|
|
|
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
|
2013-10-26 04:24:40 +02:00
|
|
|
'LOCATION': 'zulip-database-test-cache',
|
2013-07-02 23:29:00 +02:00
|
|
|
'TIMEOUT': 3600,
|
2013-11-08 17:35:40 +01:00
|
|
|
'CONN_MAX_AGE': 600,
|
2013-07-02 23:29:00 +02:00
|
|
|
'OPTIONS': {
|
|
|
|
'MAX_ENTRIES': 100000
|
|
|
|
}
|
|
|
|
}
|
2013-01-22 23:16:56 +01:00
|
|
|
|
2016-03-10 17:17:40 +01:00
|
|
|
# Enable file:/// hyperlink support by default in tests
|
|
|
|
ENABLE_FILE_LINKS = True
|
|
|
|
|
2013-08-06 22:51:47 +02:00
|
|
|
LOGGING['loggers']['zulip.requests']['level'] = 'CRITICAL'
|
2013-11-19 00:04:45 +01:00
|
|
|
LOGGING['loggers']['zulip.management']['level'] = 'CRITICAL'
|
2016-12-19 10:22:10 +01:00
|
|
|
LOGGING['loggers']['django.request'] = {'level': 'ERROR'}
|
2016-12-30 16:05:21 +01:00
|
|
|
LOGGING['loggers']['fakeldap'] = {'level': 'ERROR'}
|
2015-08-20 20:07:52 +02:00
|
|
|
|
2016-07-09 19:01:36 +02:00
|
|
|
LOCAL_UPLOADS_DIR = 'var/test_uploads'
|
2016-04-20 21:51:21 +02:00
|
|
|
|
|
|
|
S3_KEY = 'test-key'
|
|
|
|
S3_SECRET_KEY = 'test-secret-key'
|
|
|
|
S3_AUTH_UPLOADS_BUCKET = 'test-authed-bucket'
|
2016-07-19 14:35:08 +02:00
|
|
|
REALMS_HAVE_SUBDOMAINS = bool(os.getenv('REALMS_HAVE_SUBDOMAINS', False))
|
2016-05-11 19:29:29 +02:00
|
|
|
|
|
|
|
# Test Custom TOS template rendering
|
|
|
|
TERMS_OF_SERVICE = 'corporate/terms.md'
|
2016-10-27 12:06:44 +02:00
|
|
|
|
|
|
|
INLINE_URL_EMBED_PREVIEW = False
|