From 9939872032e8f7d2a374a696e58a5edf04188b8a Mon Sep 17 00:00:00 2001 From: Jan Mach <jan.mach@cesnet.cz> Date: Sat, 19 Mar 2022 07:15:11 +0100 Subject: [PATCH] Initial work to make unit tests, well, work. (Redmine issue: #7494) --- MANIFEST.in | 1 + conf/requirements.pip | 1 + lib/hawat/test/runner.py | 1 + lib/vial/config.py | 2 ++ lib/vial/log.py | 3 +++ lib/vial/test/runner.py | 1 + vagrantenv/provisioning/p02_mentat.sh | 5 +++++ 7 files changed, 14 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index 9b61621e9..1a38294a6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ include LICENSE.txt include README.rst +include lib/hawat/babel.cfg include lib/hawat/Makefile* recursive-include lib/mentat/templates_email * recursive-include lib/hawat/static * diff --git a/conf/requirements.pip b/conf/requirements.pip index bac2a760b..ec7fde8cc 100644 --- a/conf/requirements.pip +++ b/conf/requirements.pip @@ -34,3 +34,4 @@ typedcols==0.1.13 idea-format==0.1.11 python-dateutil==2.8.1 PyBabel-json-md==0.1.0 +itsdangerous==2.0.1 diff --git a/lib/hawat/test/runner.py b/lib/hawat/test/runner.py index 8e8ea2e7a..27838f1f8 100644 --- a/lib/hawat/test/runner.py +++ b/lib/hawat/test/runner.py @@ -40,6 +40,7 @@ def _config_testapp_hawat(app_config): app_config['MAIL_PORT'] = 1025 app_config['MAIL_DEFAULT_SENDER'] = 'root@unittest' app_config['EMAIL_ADMINS'] = ['admin@unittest'] + app_config['DISABLE_MAIL_LOGGING'] = True app_config['MODELS'] = { vial.const.MODEL_USER: UserModel, vial.const.MODEL_GROUP: GroupModel, diff --git a/lib/vial/config.py b/lib/vial/config.py index da18c213e..9c682397a 100644 --- a/lib/vial/config.py +++ b/lib/vial/config.py @@ -60,6 +60,8 @@ class Config: # pylint: disable=locally-disabled,too-few-public-methods MAIL_DEFAULT_SENDER = '{}@{}'.format(APPLICATION_ID, socket.getfqdn()) MAIL_SUBJECT_PREFIX = '[{}]'.format(APPLICATION_NAME) + DISABLE_MAIL_LOGGING = False + # # Flask-Babel configurations. # diff --git a/lib/vial/log.py b/lib/vial/log.py index 4c20e0223..13f5d2e65 100644 --- a/lib/vial/log.py +++ b/lib/vial/log.py @@ -76,6 +76,9 @@ def setup_logging_email(app): """ Setup application logging via email. """ + if app.config['DISABLE_MAIL_LOGGING']: + return app + log_level_str = app.config['LOG_EMAIL_LEVEL'].upper() log_level = getattr( logging, diff --git a/lib/vial/test/runner.py b/lib/vial/test/runner.py index 01180cc87..8854446a3 100644 --- a/lib/vial/test/runner.py +++ b/lib/vial/test/runner.py @@ -36,6 +36,7 @@ def _config_testapp_vial(app_config): app_config['MAIL_PORT'] = 1025 app_config['MAIL_DEFAULT_SENDER'] = 'root@unittest' app_config['EMAIL_ADMINS'] = ['admin@unittest'] + app_config['DISABLE_MAIL_LOGGING'] = True app_config['MODELS'] = { vial.const.MODEL_USER: vial.model.db.UserModel, vial.const.MODEL_GROUP: vial.model.db.GroupModel, diff --git a/vagrantenv/provisioning/p02_mentat.sh b/vagrantenv/provisioning/p02_mentat.sh index e9990ce43..d1582db5d 100644 --- a/vagrantenv/provisioning/p02_mentat.sh +++ b/vagrantenv/provisioning/p02_mentat.sh @@ -133,4 +133,9 @@ if [ ! -L /etc/apache2/sites-enabled/site_mentat_vagrant.conf ] ; then systemctl restart apache2.service fi +print_subtitle 'Creating stubs for unit tests' +mkdir -p /vagrant/chroot +ln -s /etc /vagrant/chroot/etc +ln -s /var /vagrant/chroot/var + print_title '<DONE> PROVISIONING MENTAT SYSTEM' -- GitLab