Changeset - 163d1c4f2b8b
[Not reviewed]
default
1 4 0
Mads Kiilerich - 8 years ago 2017-09-14 02:08:07
mads@kiilerich.com
tests: generate test.ini directly from template

Get rid of the committed generated test.ini
5 files changed with 24 insertions and 475 deletions:
0 comments (0 inline, 0 general)
MANIFEST.in
Show inline comments
 
@@ -15,15 +15,14 @@ include           tox.ini
 
recursive-include docs *
 
recursive-include init.d *
 
recursive-include kallithea/alembic *
 
include           kallithea/bin/ldap_sync.conf
 
include           kallithea/lib/paster_commands/template.ini.mako
 
recursive-include kallithea/i18n *
 
recursive-include kallithea/public *
 
recursive-include kallithea/templates *
 
recursive-include kallithea/tests/fixtures *
 
recursive-include kallithea/tests/scripts *
 
include           kallithea/tests/models/test_dump_html_mails.ref.html
 
include           kallithea/tests/performance/test_vcs.py
 
include           kallithea/tests/test.ini
 
include           kallithea/tests/vcs/aconfig
 
recursive-include scripts *
kallithea/tests/conftest.py
Show inline comments
 
@@ -3,60 +3,75 @@ import re
 
import sys
 
import logging
 
import pkg_resources
 
import time
 

	
 
import formencode
 
from paste.deploy import loadwsgi
 
from routes.util import URLGenerator
 
import pytest
 
from pytest_localserver.http import WSGIServer
 

	
 
from kallithea.controllers.root import RootController
 
from kallithea.lib import inifile
 
from kallithea.lib.utils import repo2db_mapper
 
from kallithea.model.user import UserModel
 
from kallithea.model.meta import Session
 
from kallithea.model.db import Setting, User, UserIpMap
 
from kallithea.model.scm import ScmModel
 
from kallithea.tests.base import invalidate_all_caches, TEST_USER_REGULAR_LOGIN, TESTS_TMP_PATH, \
 
    TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS
 
import kallithea.tests.base # FIXME: needed for setting testapp instance!!!
 

	
 
from tg.util.webtest import test_context
 

	
 

	
 
def pytest_configure():
 
    os.environ['TZ'] = 'UTC'
 
    if not kallithea.is_windows:
 
        time.tzset() # only available on Unix
 

	
 
    path = os.getcwd()
 
    sys.path.insert(0, path)
 
    pkg_resources.working_set.add_entry(path)
 

	
 
    # Disable INFO logging of test database creation, restore with NOTSET
 
    logging.disable(logging.INFO)
 

	
 
    with open(os.path.join(path, 'kallithea/tests/test.ini'), 'r') as input_file:
 
        test_ini = input_file.read()
 

	
 
    ini_settings = {
 
        '[server:main]': {
 
            'port': '4999',
 
        },
 
        '[app:main]': {
 
            'app_instance_uuid': 'test',
 
            'show_revision_number': 'true',
 
            'beaker.cache.sql_cache_short.expire': '1',
 
            'beaker.session.secret': '{74e0cd75-b339-478b-b129-07dd221def1f}',
 
        },
 
        '[handler_console]': {
 
            'formatter': 'color_formatter',
 
        },
 
        # The 'handler_console_sql' block is very similar to the one in
 
        # development.ini, but without the explicit 'level=DEBUG' setting:
 
        # it causes duplicate sqlalchemy debug logs, one through
 
        # handler_console_sql and another through another path.
 
        '[handler_console_sql]': {
 
            'formatter': 'color_formatter_sql',
 
        },
 
    }
 
    if os.environ.get('TEST_DB'):
 
        test_ini = re.sub('^\s*sqlalchemy.url\s*=.*$',
 
                           'sqlalchemy.url = %s' % os.environ.get('TEST_DB'),
 
                           test_ini,
 
                           flags=re.M)
 
        ini_settings['[app:main]']['sqlalchemy.url'] = os.environ.get('TEST_DB')
 

	
 
    test_ini_file = os.path.join(TESTS_TMP_PATH, 'test.ini')
 
    with open(test_ini_file, 'w') as output_file:
 
        output_file.write(test_ini)
 
    inifile.create(test_ini_file, None, ini_settings)
 

	
 
    context = loadwsgi.loadcontext(loadwsgi.APP, 'config:%s' % test_ini_file)
 
    from kallithea.tests.fixture import create_test_env, create_test_index
 

	
 
    # set KALLITHEA_NO_TMP_PATH=1 to disable re-creating the database and test repos
 
    if not int(os.environ.get('KALLITHEA_NO_TMP_PATH', 0)):
 
        create_test_env(TESTS_TMP_PATH, context.config())
 

	
 
    # set KALLITHEA_WHOOSH_TEST_DISABLE=1 to disable whoosh index during tests
 
    if not int(os.environ.get('KALLITHEA_WHOOSH_TEST_DISABLE', 0)):
 
        create_test_index(TESTS_TMP_PATH, context.config(), True)
 

	
kallithea/tests/test.ini
Show inline comments
 
deleted file
scripts/generate-ini.py
Show inline comments
 
@@ -2,47 +2,24 @@
 
"""
 
Based on kallithea/lib/paster_commands/template.ini.mako, generate
 
  development.ini
 
  kallithea/tests/test.ini
 
"""
 

	
 
import re
 

	
 
from kallithea.lib import inifile
 

	
 
# files to be generated from the mako template
 
ini_files = [
 
    ('kallithea/tests/test.ini',
 
        {
 
            '[server:main]': {
 
                'port': '4999',
 
            },
 
            '[app:main]': {
 
                'app_instance_uuid': 'test',
 
                'show_revision_number': 'true',
 
                'beaker.cache.sql_cache_short.expire': '1',
 
                'beaker.session.secret': '{74e0cd75-b339-478b-b129-07dd221def1f}',
 
            },
 
            '[handler_console]': {
 
                'formatter': 'color_formatter',
 
            },
 
            # The 'handler_console_sql' block is very similar to the one in
 
            # development.ini, but without the explicit 'level=DEBUG' setting:
 
            # it causes duplicate sqlalchemy debug logs, one through
 
            # handler_console_sql and another through another path.
 
            '[handler_console_sql]': {
 
                'formatter': 'color_formatter_sql',
 
            },
 
        },
 
    ),
 
    ('development.ini',
 
        {
 
            '[server:main]': {
 
                'host': '0.0.0.0',
 
            },
 
            '[app:main]': {
 
                'initial_repo_scan': 'true',
 
                'debug': 'true',
 
                'app_instance_uuid': 'development-not-secret',
 
                'beaker.session.secret': 'development-not-secret',
 
            },
 
            '[handler_console]': {
scripts/manifest
Show inline comments
 
@@ -909,25 +909,24 @@ kallithea/tests/models/test_user_permiss
 
kallithea/tests/models/test_users.py
 
kallithea/tests/other/
 
kallithea/tests/other/__init__.py
 
kallithea/tests/other/manual_test_vcs_operations.py
 
kallithea/tests/other/test_libs.py
 
kallithea/tests/other/test_mail.py
 
kallithea/tests/other/test_validators.py
 
kallithea/tests/scripts/
 
kallithea/tests/scripts/create_rc.sh
 
kallithea/tests/scripts/manual_test_concurrency.py
 
kallithea/tests/scripts/manual_test_crawler.py
 
kallithea/tests/scripts/mem_watch
 
kallithea/tests/test.ini
 
kallithea/tests/vcs/
 
kallithea/tests/vcs/__init__.py
 
kallithea/tests/vcs/aconfig
 
kallithea/tests/vcs/base.py
 
kallithea/tests/vcs/conf.py
 
kallithea/tests/vcs/test_archives.py
 
kallithea/tests/vcs/test_branches.py
 
kallithea/tests/vcs/test_changesets.py
 
kallithea/tests/vcs/test_filenodes_unicode_path.py
 
kallithea/tests/vcs/test_getitem.py
 
kallithea/tests/vcs/test_getslice.py
 
kallithea/tests/vcs/test_git.py
0 comments (0 inline, 0 general)